How can I avoid the "Too many requests" error on python when scraping googlenews?

738 views Asked by At

I have a python list:

['Facebook lawsuit', 'Google lawsuit', 'Whatsapp lawsuit',' Instagram lawsuit']

I need help looping through Google News to pull the top 5 news articles between [2022-01-01 to 2022-03-31]

Here's my code:

def gnews_search():
    from GoogleNews import GoogleNews
    news = GoogleNews(lang = 'en', period='90d')
    for x in list1:
        news.search(x)
        news.result()
        news.clear()
        for result in results: 
            print('\n\nTITLE:',result['title'],
            '\nDESC:',result['desc'],
            '\nURL:',result['link'])

However, when I use the above code, I am getting an error that says 'Too many requests'? Is there a way I can sleep the process for two seconds and run it for the next item in the list and so forth from the above code?

0

There are 0 answers