{"id":20639181,"url":"https://github.com/lostdir/news_scrapper","last_synced_at":"2026-01-29T00:04:38.252Z","repository":{"id":256570377,"uuid":"850698434","full_name":"lostdir/News_Scrapper","owner":"lostdir","description":"News website scraper using python beautifulsoup4","archived":false,"fork":false,"pushed_at":"2024-09-15T07:36:18.000Z","size":19,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T02:42:42.406Z","etag":null,"topics":["beautifulsoup4","scraper","webscraping"],"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/lostdir.png","metadata":{"files":{"readme":"README.md","changelog":"newscrapper.py","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}},"created_at":"2024-09-01T14:30:01.000Z","updated_at":"2025-01-18T12:04:59.000Z","dependencies_parsed_at":"2024-09-11T20:22:59.370Z","dependency_job_id":"91691c79-de7e-46d6-9f9e-48cc0d810cfe","html_url":"https://github.com/lostdir/News_Scrapper","commit_stats":null,"previous_names":["lostdir/news_scrapper"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostdir%2FNews_Scrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostdir%2FNews_Scrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostdir%2FNews_Scrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostdir%2FNews_Scrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lostdir","download_url":"https://codeload.github.com/lostdir/News_Scrapper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248533467,"owners_count":21120100,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["beautifulsoup4","scraper","webscraping"],"created_at":"2024-11-16T15:22:52.006Z","updated_at":"2026-01-29T00:04:38.225Z","avatar_url":"https://github.com/lostdir.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# News Scraper for Times of India\n\nThis project is a Python-based web scraper designed to extract news articles from the Times of India website. It allows you to scrape a random selection of articles from a specified range of years and save the extracted data (title, date, content, and URL) to a CSV file.\n\n## Table of Contents\n\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Functionality](#functionality)\n- [Dependencies](#dependencies)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Features\n\n- **Scrape Articles**: Extracts news articles from the Times of India archive pages.\n- **Error Handling**: Includes retry mechanisms and error handling to manage network issues and timeouts.\n- **Random Article Selection**: Selects random articles to scrape within a specified date range.\n- **Save to CSV**: Saves scraped articles to a CSV file for further analysis or use.\n- **Progress Bar**: Displays a progress bar to track the scraping process.\n\n## Installation\n\nTo use this scraper, you need to have Python installed. Follow the steps below to set up the project:\n\n1. **Clone the repository:**\n   ```bash\n   git clone https://github.com/lostdir/News_Scrapper.git\n   cd news_scraper\n   ```\n\n2. **Create a virtual environment:**\n   ```bash\n   python -m venv venv\n   source venv/bin/activate  # On Windows use `venv\\Scripts\\activate`\n   ```\n\n3. **Install the required dependencies:**\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n## Usage\n\nTo run the scraper, execute the following command:\n\n```bash\npython scraper.py\n```\n\nYou can modify the parameters such as the range of years and the number of articles to scrape by editing the `scrape_random_articles` function call in the `if __name__ == '__main__':` block.\n\n### Example Usage\n\n```python\nscrape_random_articles(2017, 2024, num_articles=10)\n```\n\nThis example will scrape 10 random articles between the years 2017 and 2024.\n\n## Functionality\n\n### Functions\n\n- **`scrape_archive_page(archive_url, max_retries=3)`**: Scrapes all article links from a single archive page with retries in case of failures.\n- **`scrape_article(article_url, max_retries=3)`**: Scrapes the title, content, and date from an individual article page.\n- **`scrape_random_articles(start_year, end_year, num_articles=65)`**: Scrapes a random selection of articles from a range of dates.\n\n### How It Works\n\n1. **Scrape Archive Pages**: The script navigates through the Times of India archive pages and extracts article URLs.\n2. **Scrape Article Content**: For each article URL, it scrapes the title, content, and date.\n3. **Random Selection**: The script selects random articles to ensure a diverse dataset.\n4. **Save to CSV**: The scraped data is saved in a CSV file named `times_of_india_articles.csv`.\n\n## Dependencies\n\nThe scraper relies on the following Python libraries:\n\n- `requests`: To send HTTP requests to the Times of India server.\n- `beautifulsoup4`: To parse and extract information from HTML pages.\n- `pandas`: To handle data and save it to a CSV file.\n- `tqdm`: To display a progress bar for the scraping process.\n\nInstall all dependencies using:\n\n```bash\npip install -r requirements.txt\n```\n\n## Contributing\n\nContributions are welcome! If you have any improvements or new features to suggest, please open an issue or submit a pull request.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flostdir%2Fnews_scrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flostdir%2Fnews_scrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flostdir%2Fnews_scrapper/lists"}