Iceloof/GoogleNews

GoogleNews search is not working, please help

SamratDey112358 opened this issue · 11 comments

googlenews.search("<any keyword") is giving "'NoneType' object is not iterable" in Python

Are you using the latest version? I can see both .get_news() and .search() can return a list of result with latest version

Hi, am using version 1.6.9, just upgraded it

Try to use browser to open google and search something with same pc, and check whether Google does robot verification or not. This may be Google recognize your behaviour as robot and do extra verification, then will cause this issue. Otherwise it seems not code issue.

No I am not getting any message about Google doing robot verification, can search as usual on browser
also same issue in multiple systems
have also tried with different internet connections

user_agent = 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:64.0) Gecko/20100101 Firefox/64.0'
headers = {'User-Agent': user_agent}
url='https://www.google.com/search?q=%3Cany%20keyword&lr=lang_en&biw=1920&bih=976&source=lnt&tbs=lr:lang_1en,qdr:10d,,sbd:1&tbm=nws&start=0'
req = urllib.request.Request(url.replace("search?","search?hl="+self.__lang+"&gl="+self.__lang+"&"), headers=headers)
response = urllib.request.urlopen(req)
page = response.read()

Try this code and see whether you can get the details

"self" is not defined, can I change it to "en"?

"self" is not defined, can I change it to "en"?

yes, just set your language

it ran, there is an output for page which is a huge chunk of string like this "b'<!doctype html><title><any keyword - Google Search</title><script nonce="6vxUfkd6PyUHdTRbAUknnA">(function(){\ndocument.documentElement.addEventListener("submit",function(b){var a;if(a=b.target){var c=a.getAttribute("data-submitfalse");a="1"===c||"q"===c&&!a.elements.q.value?!0:!1}else a=!1;a&&(b.preventDefault(),b.stopPropagation())},!0);document.documentElement.addEventListener("click",function(b){var a;a:{for(a=b.target;a&&a!==document.documentElement......."

Hi, any ideas?

try to open the url directly, and then find some title, try to search the title in this string, or you can try the source code https://github.com/Iceloof/GoogleNews/blob/master/GoogleNews/__init__.py

Hi, am getting results by using the source code, however the news of correct date range is not being captured (dates outside defined range) and also, the urls are being formatted differently (some string+url ="url"&ved+some string).