Iceloof / GoogleNews

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

get_news() search returning 'NoneType' error #133

Closed wcorona269 closed 6 months ago

wcorona269 commented 6 months ago

I am getting an error while attempting to use the get_news() function. I have checked the version using gNews.getVersion() and it shows 1.6.11. Half of the time i use the get_news() function it works, half the time it returns a blank list, but every time i get the same 2 errors logged repeatedly.

my code:

gNews = GoogleNews(period='20d')
gNews.get_news(topic)

The error:

 'NoneType' object has no attribute 'parent'
'NoneType' object has no attribute 'startswith'
samwesley commented 6 months ago

I'm seeing the same issue. I was able to get around it when testing by changing this: link = 'news.google.com/' + article.find("h4").parent.get("href")[2:] to this: link = 'news.google.com/' + article.find("a").get("href")[2:] in init.py

@HurinHu I don't know what articles looked like before (or if their format changed), but I don't think there is an h4 in them currently

HurinHu commented 6 months ago

Issue solved with latest version 1.6.12

jlchen14 commented 6 months ago

Thank you very much for your timely feedback and action~ saved my little project~