Iceloof / GoogleNews

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

datetime returns NaN when date has month on it #114

Closed MelchiorHakimi closed 1 year ago

MelchiorHakimi commented 1 year ago

If a news article has a date in this format: "18 days ago" I get a datetime in this format: "2023-03-03 2:24:53"

That's good. However, when the date is in this format: "Feb 21" I get NaN as datetime.

How to solve? Thanks!

HurinHu commented 1 year ago

Some results are not returned in the proper format from Google, then you may not able to get the exact date time.

MelchiorHakimi commented 1 year ago

Ah, so you are saying that it is Google sending bad information when the "Feb 21" format is used.

I guess for my use, then, I simply create a datetime based on the date returned so I have my datetimes in a consistent form. Too bad Google sends datetime that way.

Anywho, great project, thanks!

MelchiorHakimi commented 1 year ago

Actually this seems to be a problem with define_date(date) as you can see... results.append({'title': tmp_text, 'media': tmp_media,'date': tmp_date,'datetime':define_date(tmp_date),'desc': tmp_desc, 'link': tmp_link,'img': tmp_img}) datetime is something computed by GoogleNews (as in this project) and not something sent by Google News (as in the service).

HurinHu commented 1 year ago

Actually this seems to be a problem with define_date(date) as you can see... results.append({'title': tmp_text, 'media': tmp_media,'date': tmp_date,'datetime':define_date(tmp_date),'desc': tmp_desc, 'link': tmp_link,'img': tmp_img}) datetime is something computed by GoogleNews (as in this project) and not something sent by Google News (as in the service).

I have fixed this issue, please update to the latest version.