https://github.com/santhoshse7en/news-fetch
A Python Package which helps to scrape all news details from any news websites
https://github.com/santhoshse7en/news-fetch
extracts felix google-search-using-python keyword lucas news news-details news-please news-website newspaper3k python scraper scraper-engine
Last synced: 5 days ago
JSON representation
A Python Package which helps to scrape all news details from any news websites
- Host: GitHub
- URL: https://github.com/santhoshse7en/news-fetch
- Owner: santhoshse7en
- License: mit
- Created: 2019-06-29T08:16:49.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-11-03T07:12:34.000Z (7 months ago)
- Last Synced: 2025-05-08T02:18:15.259Z (13 days ago)
- Topics: extracts, felix, google-search-using-python, keyword, lucas, news, news-details, news-please, news-website, newspaper3k, python, scraper, scraper-engine
- Language: Python
- Homepage:
- Size: 49.8 KB
- Stars: 199
- Watchers: 9
- Forks: 110
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: newsfetch/__init__.py
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[](https://pypi.org/project/news-fetch)
[](https://pypi.python.org/pypi/news-fetch/)
[](https://santhoshse7en.github.io/news-fetch_doc)# news-fetch
**news-fetch** is an open-source, easy-to-use news crawler that extracts structured information from almost any news website. It can recursively follow internal hyperlinks and read RSS feeds to fetch both recent and archived articles. You only need to provide the root URL of the news website to crawl it completely. News-fetch combines the power of multiple state-of-the-art libraries and tools, including [news-please](https://github.com/fhamborg/news-please) by [Felix Hamborg](https://www.linkedin.com/in/felixhamborg/) and [Newspaper3K](https://github.com/codelucas/newspaper/) by [Lucas (欧阳象) Ou-Yang](https://www.linkedin.com/in/lucasouyang/). This package leverages features from both of these works.
I built this tool to minimize NaN or empty values when scraping data from various news websites. It's platform-independent and written in Python 3, making it easy for programmers and developers to access news data for their applications.
| Source | Link |
| -------------- | ---------------------------------------------------------------------- |
| PyPI: | [https://pypi.org/project/news-fetch/](https://pypi.org/project/news-fetch/) |
| Repository: | [https://santhoshse7en.github.io/news-fetch/](https://santhoshse7en.github.io/news-fetch/) |
| Documentation: | [https://santhoshse7en.github.io/news-fetch_doc/](https://santhoshse7en.github.io/news-fetch_doc/) (**Not Yet Created!**) |## Dependencies
- [news-please](https://pypi.org/project/news-please/)
- [newspaper3k](https://pypi.org/project/newspaper3k/)
- [beautifulsoup4](https://pypi.org/project/beautifulsoup4/)
- [selenium](https://pypi.org/project/selenium/)## Extracted Information
news-fetch extracts the following attributes from news articles. You can also check out an [example JSON file](https://github.com/santhoshse7en/news-fetch/blob/master/newsfetch/example/sample.json) generated by news-please.
- Headline
- Author(s)
- Publication date
- Publication
- Category
- Source domain
- Article content
- Summary
- Keywords
- URL
- Language## Dependency Installation
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install the required dependencies:
```bash
pip install -r requirements.txt
```## Usage
You can download it by clicking the green download button on [Github](https://github.com/santhoshse7en/news-fetch/archive/master.zip).
To scrape all the news details, use the `newspaper` function:
```python
from newsfetch.news import Newspapernews = Newspaper(url='https://www.thehindu.com/news/cities/Madurai/aa-plays-a-pivotal-role-in-helping-people-escape-from-the-grip-of-alcoholism/article67716206.ece')
print(news.headline)
# Output: 'AA plays a pivotal role in helping people escape from the grip of alcoholism'
```To extract URLs from a targeted website, call the `GoogleSearchNewsURLExtractor` by providing the keyword and newspaper link as arguments:
```python
from newsfetch.google import GoogleSearchNewsURLExtractorgoogle = GoogleSearchNewsURLExtractor(keyword='Alcoholics Anonymous', news_domain='https://timesofindia.indiatimes.com/')
print(google.urls)
"""
['https://timesofindia.indiatimes.com/city/pune/pune-takes-a-stand-against-alcoholism-experts-collaborate-with-alcoholics-anonymous/articleshow/114438466.cms',
'https://timesofindia.indiatimes.com/city/mumbai/we-have-lost-jobs-homes-alcoholics-anonymous/articleshow/96824383.cms',
'https://timesofindia.indiatimes.com/city/gurgaon/gurgaons-alcoholics-open-up-about-their-road-to-recovery/articleshow/45080744.cms',
'https://timesofindia.indiatimes.com/city/goa/alcoholism-is-illness-not-issue-of-weak-willpower-say-experts/articleshow/105320008.cms',
'https://timesofindia.indiatimes.com/city/bhopal/alcoholism-is-an-illness-bhopal-aa-silver-jubilee-celebration/articleshow/106849014.cms',
'https://timesofindia.indiatimes.com/city/ahmedabad/alcoholics-anonymous-switches-to-online-sessions/articleshow/76144639.cms',
'https://timesofindia.indiatimes.com/city/kochi/keralites-trying-to-kick-alcoholism-alcoholics-anonymous/articleshow/13977818.cms',
'https://timesofindia.indiatimes.com/city/chandigarh/alcoholics-anonymous-turned-their-lives-around/articleshow/18239.cms',
'https://timesofindia.indiatimes.com/city/mumbai/like-air-india-flyer-alcoholics-anonymous-members-reap-whirlwind-of-job-loss-broken-homes/articleshow/96820403.cms',
'https://timesofindia.indiatimes.com/city/nagpur/alcoholics-anonymous-meet-promotes-one-day-at-a-time/articleshow/50538092.cms']
"""
```## Contributing
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
Make sure to update tests as appropriate.
## License
This project is licensed under the [MIT](https://choosealicense.com/licenses/mit/) License.