{"id":29504059,"url":"https://github.com/yaaa3ser/news-scraper","last_synced_at":"2026-04-08T18:07:08.086Z","repository":{"id":304296750,"uuid":"1018304627","full_name":"yaaa3ser/news-scraper","owner":"yaaa3ser","description":"A Dockerized news aggregator that scrapes articles from BBC, CNN, and Newsmax, stores them in a PostgreSQL database, and serves them via a FastAPI web interface with auto-refreshing HTML pages.","archived":false,"fork":false,"pushed_at":"2025-07-12T06:09:49.000Z","size":602,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-03T18:06:00.903Z","etag":null,"topics":["beautifulsoup","docker-compose","fastapi","postgresql","selenium-webdriver"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yaaa3ser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-12T01:54:44.000Z","updated_at":"2025-07-12T06:12:12.000Z","dependencies_parsed_at":"2025-07-12T08:22:12.124Z","dependency_job_id":"ebcb6a7e-132a-4cf5-9b8a-dad9cd607137","html_url":"https://github.com/yaaa3ser/news-scraper","commit_stats":null,"previous_names":["yaaa3ser/news-scraper"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yaaa3ser/news-scraper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaaa3ser%2Fnews-scraper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaaa3ser%2Fnews-scraper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaaa3ser%2Fnews-scraper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaaa3ser%2Fnews-scraper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yaaa3ser","download_url":"https://codeload.github.com/yaaa3ser/news-scraper/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaaa3ser%2Fnews-scraper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31567364,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["beautifulsoup","docker-compose","fastapi","postgresql","selenium-webdriver"],"created_at":"2025-07-15T23:01:43.361Z","updated_at":"2026-04-08T18:07:08.065Z","avatar_url":"https://github.com/yaaa3ser.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# News Scraper Service\n\nA Dockerized news aggregation system that scrapes articles from multiple news sources (BBC, CNN, and Newsmax), stores them in a PostgreSQL database, and provides a modern web interface for viewing articles.\n\n## Overview\n\nThis service consists of three main components:\n1. **Three independent Python microservices** for scraping news from different sources\n2. **PostgreSQL database** for storing articles with deduplication\n3. **FastAPI web server** with HTML interface for viewing articles\n\n## Architecture\nThe system uses the following services:\n\n1. **BBC RSS Scraper** (`scrapers/bbc_scraper.py`)\n   - Fetches articles from multiple BBC RSS feeds in the last 24 hours\n   - Covers categories: World, Technology, Health, Education, Science \u0026 Environment\n\n2. **CNN Homepage Scraper** (`scrapers/cnn_scraper.py`)\n   - Scrapes CNN.com homepage directly (no RSS)\n   - Uses BeautifulSoup for HTML parsing\n\n3. **Newsmax Homepage Scraper** (`scrapers/newsmax_scraper.py`)\n   - Scrapes Newsmax.com homepage using Selenium WebDriver (chrome for testing)\n   - Uses headless Chrome browser for JavaScript rendering\n   - Handles dynamic content loading\n\n### Database Schema\nPostgreSQL database with the following table structure:\n```sql\nCREATE TABLE articles (\n    title_of_article TEXT UNIQUE,\n    url_of_article TEXT UNIQUE,\n    full_content_of_article TEXT,\n    main_picture_of_article_url TEXT,\n    published_utc TIMESTAMP WITH TIME ZONE,\n    fetch_datetime_utc TIMESTAMP WITH TIME ZONE,\n    main_category TEXT\n);\n```\n\n### Deduplication Strategy\n- **Primary deduplication**: Uses database UNIQUE constraints on both `title_of_article` and `url_of_article`\n- **Secondary check**: Before insertion, queries existing articles by URL and title\n- **Performance optimization**: Database indexes on URL and title fields for fast lookups\n\n## Features\n\n### Core Functionality\n- **Continuous Operation**: All scrapers run every 60 seconds automatically\n- **Initial Bulk Fetch**: Fetches all available articles on first launch\n- **Smart Deduplication**: Prevents duplicate articles using efficient database queries\n- **Metadata Capture**: Stores title, URL, content, main image, publication time, fetch time, and category\n\n\n## How to Use\n\n### Prerequisites\n- Docker and Docker Compose installed\n- Internet connection for scraping news websites\n\n### Quick Start\n1. **Clone and navigate to the project directory**\n   ```bash\n   cd news-scraper\n   ```\n\n2. **Start all services**\n   ```bash\n   docker-compose up -d\n   ```\n\n3. **Access the web interface**\n   - Open your browser and go to: `http://localhost:8000/static/news.html`\n   - The interface will automatically start displaying articles as they are scraped\n\n4. **Monitor the services**\n   ```bash\n   # View logs for all services\n   docker-compose logs -f\n   \n   # View logs for specific scraper\n   docker-compose logs -f bbc\n   docker-compose logs -f cnn\n   docker-compose logs -f newsmax\n   ```\n\n### Service Endpoints\n- **Web Interface**: `http://localhost:8000/static/news.html`\n- **API Articles List**: `http://localhost:8000/articles`\n- **API Single Article**: `http://localhost:8000/article?url=\u003carticle_url\u003e`\n- **PostgreSQL**: `localhost:5432` (credentials: postgres/password)\n\n## Technical Implementation\n\n### Base Scraper Class\nAll scrapers inherit from `BaseScraper` class which provides:\n- Database connection management\n- Article saving with deduplication logic\n- Continuous execution with error handling\n\n\n### Anti-Scraping Countermeasures (Newsmax)\n- **Headless Browser**: Uses Selenium with Chrome WebDriver\n- **User Agent Rotation**: Custom user agent strings\n- **Request Delays**: Built-in delays between requests\n- **Browser Options**: Disabled automation detection features\n\n## File Structure\n```\nnews-scraper/\n├── docker-compose.yml          # Container orchestration\n├── Dockerfile                  # Container build instructions\n├── requirements.txt            # Python dependencies\n├── init_db.sql                 # Database schema\n├── api/\n│   └── api.py                  # FastAPI web server\n├── scrapers/\n│   ├── __init__.py\n│   ├── base_scraper.py        # Base class for all scrapers\n│   ├── bbc_scraper.py         # BBC RSS scraper\n│   ├── cnn_scraper.py         # CNN homepage scraper\n│   └── newsmax_scraper.py     # Newsmax scraper with Selenium\n└── static/\n    ├── news.html              # Main news listing page\n    └── article.html           # Individual article view page\n```\n\n## Screenshots\n![News Interface](./samples/news.png)\n![Article Interface](./samples/article.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaaa3ser%2Fnews-scraper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyaaa3ser%2Fnews-scraper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaaa3ser%2Fnews-scraper/lists"}