Closed GregorKerr1996 closed 3 years ago
I found this problem too when I want to get specific keywords, but I found that something interesting, you can slightly lower the range of the date because at the first attempt I found a NoneType problem too.
My suggestion is lowering the range of date, maybe just for 1-2 days and one keyword first, and then you can increasing step by step.
from GoogleNews import GoogleNews googlenews = GoogleNews()
googlenews = GoogleNews(start='17/02/2021',end='22/02/2021')
news_keywords = ["Apple","Microsoft"etc]
check = ['17/02/2021','18/02/2021','19/02/2021','20/02/2021','21/02/2021','22/02/2021'] cols =['Date','Title','Description','provider','company'] lst = [] for i in news_keywords: print(i) googlenews.search(i) googlenews.get_page(1) googlenews.get_page(2) etc
currently returns Apple 'NoneType' object is not iterable 'NoneType' object is not iterable 'NoneType' object is not iterable
for multiple companies over this time period. Have ran the same code for each week over the past months so unsure if mabye im doing something wrong with latest update?
hmm, needing data for the past week so this doesn't necessarily fix my problem, but thanks for your suggestion
Likewise I have found the same 'NoneType' object is not iterable
There are few mistakes in your code, you only need to create constructor once, and the date format should be mm/dd/yyyy, and the result should be retrieved by googlenews.results()
, and please add delay few seconds within the loop, if you request too frequent, Google may block your IP. The return list should be something like [{'title':'xxx','media':'xxx','date':'xxx','datetime':'xxx','desc':'xxx','link':'xxx','img':'xxx'},{...}...]
from GoogleNews import GoogleNews
- googlenews = GoogleNews()
- (it is not necessary here, it will be reset by the next line)
- googlenews = GoogleNews(start='17/02/2021',end='22/02/2021')
+ googlenews = GoogleNews(start='02/17/2021',end='02/22/2021')
...
googlenews.search(i)
googlenews.get_page(1)
googlenews.get_page(2)
+ result = googlenews.results()
+ time.sleep(5)
from GoogleNews import GoogleNews googlenews = GoogleNews()
googlenews = GoogleNews(start='17/02/2021',end='22/02/2021')
news_keywords = ["Apple","Microsoft"etc]
check = ['17/02/2021','18/02/2021','19/02/2021','20/02/2021','21/02/2021','22/02/2021'] cols =['Date','Title','Description','provider','company'] lst = [] for i in news_keywords: print(i) googlenews.search(i) googlenews.get_page(1) googlenews.get_page(2) etc
currently returns Apple 'NoneType' object is not iterable 'NoneType' object is not iterable 'NoneType' object is not iterable
for multiple companies over this time period. Have ran the same code for each week over the past months so unsure if mabye im doing something wrong with latest update?