Build news aggregator
This guide takes you through the process of building a news aggregator with the NewsCatcher news API.
News aggregators can do a lot of things, but at the core of things, they all need to scrape, clean, and organize news information from multiple sources. In this guide, you’ll go through the process of building a news aggregator using NewsCatcher’s news API(in less than 10 mins).
Requirements
Here’s what you’ll need to follow along with this guide:
- URLs of the news outlets you want to aggregate
- Python 3
- The following Python modules
Setup
Install the required modules using pip:
Get clean URLs
To get the clean URLs of the news outlets, you can use the following function:
If you’re working with international news outlets and want a specific regional
website, you can use the lang
parameter to get it. For example, if you want to
get the news articles for 'arabic.rt.com'
and 'francais.rt.com'
, you can’t
just use the clean URL because it will be the same for both of them, 'rt.com'
.
Get news articles
Once you have the clean URLs of the news sources you want to aggregate, you can
simply pass them as a list to the sources parameter of the v2/search
endpoint
to get the articles. And that’s it!
Let’s say you wanted to aggregate all news articles from The New York Times and The Guardian published in the last week.
All you would need to do is use the get_search()
method to fetch the articles:
Alternatively, if you’re not working with Python you can make a GET request with the clean URLs:
Which would yield a JSON/Dictionary object that looks like this:
You can now extract the articles list from this and use them however you like.
Check out this nifty crypto news aggregator we made.
Did we miss any outlets you need? Reach out to us at team@newscatcherapi.com, we’ll add it without breaking a sweat.
Was this page helpful?