Scrape Trending News using Python

Most of the datasets that you find from different data sources on the internet are created by collecting data from websites. Using the GoogleNews API in Python, we can scrape trending updates based on any keyword or country. In this article, I’ll walk you through how to scrape trending news using Python.

Scrape Trending News using Python

The GoogleNews API can be used to scrape live news updates and the latest trends from around the world based on any topic. It allows you to retrieve information on any keyword which can be the name of any country, any event or even the name of a person who is trending on Google. If you have never used this API before, you can easily install it on your systems using the pip command; pip install googlenews.

Now let’s see how to scrape trending news using Python. I will first import the necessary Python libraries and then I will scrape the latest trending news about India. As the returning output will be in the form of a dictionary so I will convert it into a pandas DataFrame:

trending news using python

In the above DataFrame, I have dropped the column “img” as it is of no use. As the resulting output is now in the DataFrame we cannot click on the links to read the complete news. So to read the complete news, I will run a for loop on the resulting dictionary so that we can get the complete link of the news article:

Output:
Title :  Coronavirus Lockdown India News Live Updates: Covid-19 ...
News :  Coronavirus (Covid-19) India Lockdown News Live Updates: This is for the first time after four straight days that the country has seen less than 4,00,000 new Covid ...
Read Full News :  https://indianexpress.com/article/india/coronavirus-india-live-updates-delhi-maharashtra-karnataka-vaccine-lockdown-7307746/
Title :  India-UAE travel suspension: New rules for charter flights
News :  As per new regulations, a single India-UAE ticket on board a private jet could cost anything between Dh22,000 to Dh25,000. Advertisement. Effective ...
Read Full News :  https://www.khaleejtimes.com/coronavirus-pandemic/india-uae-travel-suspension-new-rules-for-charter-flights
Title :  National lockdown, just not in name: Almost 98% of India is ...
News :  As of now, restrictions are in place across 28 states and eight union territories in India. In some parts, containment measures are localised and confined to a few ...
Read Full News :  https://www.indiatoday.in/diu/story/26-states-uts-under-some-lockdown-india-s-score-on-global-stringency-index-jumps-to-74-1800507-2021-05-09
Title :  Australia's federal court rejects urgent bid to overturn India ...
News :  Judge sides with health minister, meaning almost 10,000 Australians in India cannot return until ban ends on Friday. Air India planes in Mumbai. Australians ...
Read Full News :  https://www.theguardian.com/australia-news/2021/may/10/australias-federal-court-rejects-urgent-bid-to-overturn-india-travel-ban
Title :  Federal Court dismisses part of a challenge to the Australian ...
News :  The ban was challenged in the Federal Court by an Australian man stranded in India's south; ​A Federal Court judge has thrown out part of the man's case.
Read Full News :  https://www.abc.net.au/news/2021-05-10/federal-court-judge-throws-out-part-of-india-travel-ban/100129520
Title :  Legal challenge against India travel ban rejected in the ...
News :  A bid to overturn Australia's ban on travellers returning from India has been rejected in court. The challenge was lodged in the Federal Court on the grounds it ...
Read Full News :  https://www.9news.com.au/national/australia-india-travel-ban-rejected-by-federal-court/f49670d3-c45d-44cc-8572-3d1747294bf8
Title :  COVID crisis: Honda India Foundation earmarks Rs 6.5 cr to ...
News :  NEW DELHI: Honda India Foundation, the corporate social responsibility arm of all Honda group companies in India, on Monday said it has earmarked Rs 6.5 ...
Read Full News :  https://www.newindianexpress.com/business/2021/may/10/covid-crisis-honda-india-foundation-earmarks-rs-65-cr-to-support-relief-efforts-2300764.html
Title :  India fastest country to administer over 17 crore Covid vaccine ...
News :  India took only 114 days to administer 17 crore doses of the Covid-19 vaccine, the fastest country to do so, the Union Health Ministry said on Monday.
Read Full News :  https://www.livemint.com/news/india/india-fastest-country-globally-to-administer-17-crore-covid-vaccine-doses-govt-11620637084158.html
Title :  Calls grow for nationwide lockdown in India as new COVID-19 ...
News :  Calls are growing for India to impose a nationwide lockdown as new coronavirus cases and deaths hold close to record highs, increasing pressure on the ...
Read Full News :  https://www.abc.net.au/news/2021-05-10/india-cases-off-peak-but-calls-grow-for-lockdown-covid19/100129612
Title :  Himanta Biswa Sarma sworn-in as 15th chief minister of ...
News :  popular from india ... Prime Minister Narendra Modi took to Twitter to congratulate Sarma post taking the oath as the chief minister. ... Himanta Biswa selected for the ...
Read Full News :  https://timesofindia.indiatimes.com/india/himanta-biswa-sarma-neda-convenor-sworn-in-as-15th-chief-minister-of-assam/articleshow/82516855.cms

Also, Read – Python Projects with Source Code.

Summary

So this is how you can scrape trending updates based on any keyword from all around the world. I hope you liked this article on how to scrape trending news using Python. Feel free to ask your valuable questions in the comments section below.

Aman Kharwal
Aman Kharwal

I'm a writer and data scientist on a mission to educate others about the incredible power of data📈.

Articles: 1433

Leave a Reply