Iceloof / GoogleNews

Script for GoogleNews
https://pypi.org/project/GoogleNews/
MIT License
314 stars 88 forks source link

Region not working #76

Closed kiddkrypto closed 2 years ago

kiddkrypto commented 2 years ago

I have tried using the region option but I get an error.

HurinHu commented 2 years ago

Region parameter is not always working, as it is not part of google search, it can only restrict to the language like this,

googlenews = GoogleNews(period='7d', encode='utf-8', lang='zh-CN', region='CN')
googlenews.search('Covid-19')
kiddkrypto commented 2 years ago

From your example that should work right? I am getting an error when I use that that region flag.

HurinHu commented 2 years ago

What error do you get? This example should work with Chinese characters result.

kiddkrypto commented 2 years ago

For Chinese or any region is get "got an unexpected keyword argument 'region'"

HurinHu commented 2 years ago

It seems you are using old version, please follow the Readme to upgrade to latest version

kiddkrypto commented 2 years ago

Ok thank you that did work.

One more question around this, my server in the USA will work for fetching Google for sentiment analysis but in Brazil it doesn't work for more than 20 minutes before it gets an error of 'http error 429: too many requests'

I have the same code on my usa server but doesn't have this error.

Can you point me in the right direction for this?

HurinHu commented 2 years ago

It is not suggested to use on server, cloud server usually will be recognized as robot by Google and it may be easily exceed the maximum request rates or even blocked.

kiddkrypto commented 2 years ago

Ok, so my problem is I have an algorithm that is using the Google news feeds but the exchange that I need to use doesn't work for USA people. While back testing from my us server it works but even backtesting from a server outside of us it doesn't work for longer than 30 minutes.

How would I get around this?

HurinHu commented 2 years ago

If it can work sometimes, but not longer than 30 minutes, then you might need to set some random delays between calls