EverythingPython

GoogleNews using Python

This article is part of something I’m building up to

I wanted to find a way in which I can get news off of Google News programatically and something that doesn’t need to me be authenticated for it. I wondered if I should build a scraper for it, but thankfully, there’s a Python package already that does it - GoogleNews on Pypi

I installed it in a new uv virtual environment using pip install googlenews and it was pretty easy to use .

For example, if I want to fetch the news for the last 1 day for Bangalore -

1>>> from GoogleNews import GoogleNews
2>>> googlenews = GoogleNews(period='1d')
3>>> googlenews.get_news('Bangalore')
4>>>for i in googlenews.results()[:10]:
5       print(i["title"])

This prints (as of today, the 22nd) the news for yesterday, the 21st of Nov -

 1Bangalore Races
 2Why a Man With MS Degree From Germany is Begging on Bengaluru Streets
 3Bengaluru ranks 7th in APAC on residential price rise
 4Bengaluru police bust honey-trapping gang for extorting ₹2.25 crore from techie
 5Bengaluru traffic police issue advisory against scams: ‘verify identities before providing information’
 6Air India to begin training facility and courses in Bengaluru for Air Craft engineers
 7Congress plans to shift winning MLAs to Bengaluru, Karnataka’s dy CM to help party’s Maha unit
 8Drug Racket Busted In Bengaluru, 318 Kg Marijuana Worth Rs 3 Crore Seized
 9IndiGo Launches Direct Flights to Mauritius from Bengaluru; Check Days, Time, & More
10Viral video: Techie found begging on Bengaluru streets

And as we can see from Google News, this is decently accurate!

Alt Text

If a new topic is desired, we must first run googlenews.clear() to flush the earlier records.

For example, if I now want to fetch the latest news about GenAI, I’ll execute -

1>>> googlenews.clear()
2>>> googlenews.get_news('Gen AI')
3>>> for i in googlenews.results()[:10]:
4...     print(f'- {i["title"]}')

Which gives me -

 1- Samsung introduces its second-gen AI model 'Gauss2': All you need to know
 2- Philips set to unveil next-gen AI MRI system
 3- The AI agenda
 4- CIOs contend with gen AI growing pains
 5- Samsung Gauss 2: Next-Gen AI Models for Efficiency, Performance, and Multilingual Support
 6- The mesmerising blue eyes of generative AI
 7- Deloitte: GenAI paving the way for transformative future for comms
 8- Capgemini, Mistral AI and Microsoft collaborate to further accelerate adoption of generative AI technologies
 9- Generative AI Tracker: Tech Industry Activity in Q2FY2025
10- AI to amplify the $2 trillion market opportunity for cybersecurity providers – McKinsey