# 20min.ch Comment Fetcher A Python script to fetch comments from 20min.ch articles using their API endpoints. This tool bypasses the need for web scraping by directly accessing the comment API. ## Features - Fetch comments for any 20min.ch article using its ID - Save comments to a JSON file for further analysis - Display comment summaries including author, text, and reactions - Show replies to comments - Search for specific keywords in comments and replies - Case-sensitive or case-insensitive search options ## Requirements - Python 3.6+ - Required packages: - requests Install the required packages: ``` pip install requests ``` ## Usage ### Basic Usage Fetch comments by article ID: ```bash python comment_fetcher.py --id 103339848 --output trump_article_comments.json ``` ### Search for Keywords Search for comments containing specific keywords: ```bash python comment_fetcher.py --id 103339848 --search EU SVP ``` Use case-sensitive search: ```bash python comment_fetcher.py --id 103339848 --search EU --case-sensitive ``` ### Command Line Arguments - `--id`: ID of the 20min.ch article (required if URL not provided) - `--url`: URL of the 20min.ch article (required if ID not provided) - `--tenant`: Tenant ID (default: 6 for German, 7 for French) - `--output`: Output file path (default: comments.json) - `--search`: Search terms to filter comments - `--case-sensitive`: Make search case-sensitive ## Output The script provides: 1. A summary of the comments (total count, whether commenting is enabled) 2. Details for each comment: - Author - Posting date/time - Text content - Reaction counts (awesome, bad, nonsense, smart, exact, unnecessary) - Reply count 3. Details for replies to comments 4. Total reaction counts across all comments and replies ## Example Output ``` Found 52 comments. Commenting is disabled. -------------------------------------------------- Comment #1: Author: SomeUser Posted: 2025-05-10 01:17:11 Text: This is a comment... Reactions: 33 awesome, 6 bad, 184 nonsense, 7 smart, 490 exact, 11 unnecessary Replies: 1 Replies: Reply by AnotherUser on 2025-05-10 00:34:46: @SomeUser This is a reply... Reactions: 46 exact, 10 nonsense, 3 bad, 4 awesome, 2 smart ``` ## How It Works The script uses the following API endpoints discovered in the 20min.ch website: - Comments API: `https://api.20min.ch/comment/v1/comments` - Comment Reactions API: `https://api.20min.ch/comment/v2/reactions` - User Reactions API: `https://api.20min.ch/comment/v1/user-reactions` The script sends requests to these endpoints with the appropriate parameters to fetch comments and their metadata. ## License This project is for educational purposes only. Use responsibly and respect the terms of service of 20min.ch.