Iceloof / GoogleNews

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

Date don't work as the expected #40

Closed davixcky closed 3 years ago

davixcky commented 3 years ago

I'm trying to get the news given a range, for example:

from GoogleNews import GoogleNews
googlenews = GoogleNews(start='02/01/2020',end='02/28/2020') 
googlenews.get_news('trump')
for new in googlenews.results(sort=True):
    print(new['date'])

But my output is this

10 minutes ago
16 minutes ago
42 minutes ago
1 hour ago
1 hour ago
1 hour ago
1 hour ago
2 hours ago
6 hours ago
6 hours ago
7 hours ago
7 hours ago
7 hours ago
8 hours ago
9 hours ago
9 hours ago
10 hours ago
10 hours ago
12 hours ago
13 hours ago
13 hours ago
16 hours ago
17 hours ago
20 hours ago
23 hours ago
Yesterday
Yesterday
Yesterday
Yesterday
Yesterday
Yesterday
Yesterday
Yesterday
Yesterday
3 days ago
3 days ago
3 days ago
3 days ago
4 days ago
4 days ago
4 days ago
4 days ago
4 days ago
4 days ago
5 days ago
6 days ago
6 days ago
6 days ago
6 days ago
7 days ago
7 days ago
7 days ago
8 days ago
8 days ago
9 days ago
10 days ago
10 days ago
10 days ago
11 days ago
11 days ago
11 days ago
11 days ago
12 days ago
13 days ago
13 days ago
13 days ago
14 days ago
14 days ago
Oct 31
Oct 31
Oct 28
Oct 27
Oct 27
Oct 26
Oct 26
Oct 26
Oct 25
Oct 24
Oct 23
Oct 23
Oct 23
Oct 22
Oct 22
Oct 22
Oct 21
Oct 21
Oct 21
Oct 21
Oct 20
Oct 20
Oct 19
Oct 19
Oct 19
Oct 18
Oct 5
Sep 1
Aug 18
Aug 10

And as you can see it's totally different of the expected. How can I fix it or it's a bug? Thanks

HurinHu commented 3 years ago

Hi David,

If you want to use the date range, you should call get_page() rather than get_news(). The method get_news() doesn’t include date range, I will investigate this later to see whether it can be added or not.

Kind Regards,

Hurin Hu

On 18/11/2020, at 12:20, David Orozco notifications@github.com wrote:



I'm trying to get the news given a range, for example:

from GoogleNews import GoogleNews googlenews = GoogleNews(start='02/01/2020',end='02/28/2020') googlenews.get_news('trump') for new in googlenews.results(sort=True): print(new['date'])

But my output is this

10 minutes ago 16 minutes ago 42 minutes ago 1 hour ago 1 hour ago 1 hour ago 1 hour ago 2 hours ago 6 hours ago 6 hours ago 7 hours ago 7 hours ago 7 hours ago 8 hours ago 9 hours ago 9 hours ago 10 hours ago 10 hours ago 12 hours ago 13 hours ago 13 hours ago 16 hours ago 17 hours ago 20 hours ago 23 hours ago Yesterday Yesterday Yesterday Yesterday Yesterday Yesterday Yesterday Yesterday Yesterday 3 days ago 3 days ago 3 days ago 3 days ago 4 days ago 4 days ago 4 days ago 4 days ago 4 days ago 4 days ago 5 days ago 6 days ago 6 days ago 6 days ago 6 days ago 7 days ago 7 days ago 7 days ago 8 days ago 8 days ago 9 days ago 10 days ago 10 days ago 10 days ago 11 days ago 11 days ago 11 days ago 11 days ago 12 days ago 13 days ago 13 days ago 13 days ago 14 days ago 14 days ago Oct 31 Oct 31 Oct 28 Oct 27 Oct 27 Oct 26 Oct 26 Oct 26 Oct 25 Oct 24 Oct 23 Oct 23 Oct 23 Oct 22 Oct 22 Oct 22 Oct 21 Oct 21 Oct 21 Oct 21 Oct 20 Oct 20 Oct 19 Oct 19 Oct 19 Oct 18 Oct 5 Sep 1 Aug 18 Aug 10

And as you can see it's totally different of the expected. How can I fix it or it's a bug? Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/Iceloof/GoogleNews/issues/40, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAX4V5HJZTGWVSITKLWHLNDSQMAMHANCNFSM4TZHB64A.

davixcky commented 3 years ago

Thanks for your response.