question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception: Could not parse your date

See original GitHub issue

I have this very simple code

gn = GoogleNews()

start = datetime.date(2018,3,1)

end = datetime.date(2019,3,1)

print(start)

gn.search(query=“car”, from_=start.strftime(‘%Y-%m-%d’), to_=end.strftime(‘%Y-%m-%d’))

but it’s giving me the error of `

AttributeError Traceback (most recent call last) /opt/anaconda3/lib/python3.8/site-packages/pygooglenews/init.py in __from_to_helper(self, validate) 89 try: —> 90 validate = parse_date(validate).strftime(‘%Y-%m-%d’) 91 return str(validate)

/opt/anaconda3/lib/python3.8/site-packages/dateparser/conf.py in wrapper(*args, **kwargs) 84 —> 85 return f(*args, **kwargs) 86 return wrapper

/opt/anaconda3/lib/python3.8/site-packages/dateparser/init.py in parse(date_string, date_formats, languages, locales, region, settings) 52 —> 53 data = parser.get_date_data(date_string, date_formats) 54

/opt/anaconda3/lib/python3.8/site-packages/dateparser/date.py in get_date_data(self, date_string, date_formats) 416 for locale in self._get_applicable_locales(date_string): –> 417 parsed_date = _DateLocaleParser.parse( 418 locale, date_string, date_formats, settings=self._settings)

/opt/anaconda3/lib/python3.8/site-packages/dateparser/date.py in parse(cls, locale, date_string, date_formats, settings) 193 instance = cls(locale, date_string, date_formats, settings) –> 194 return instance._parse() 195

/opt/anaconda3/lib/python3.8/site-packages/dateparser/date.py in _parse(self) 197 for parser_name in self._settings.PARSERS: –> 198 date_obj = self._parsersparser_name 199 if self._is_valid_date_obj(date_obj):

/opt/anaconda3/lib/python3.8/site-packages/dateparser/date.py in _try_parser(self) 221 self._settings.DATE_ORDER = self.locale.info.get(‘date_order’, _order) –> 222 date_obj, period = date_parser.parse( 223 self._get_translated_date(), settings=self._settings)

/opt/anaconda3/lib/python3.8/site-packages/dateparser/conf.py in wrapper(*args, **kwargs) 84 —> 85 return f(*args, **kwargs) 86 return wrapper

/opt/anaconda3/lib/python3.8/site-packages/dateparser/date_parser.py in parse(self, date_string, settings) 36 stz = get_localzone() —> 37 date_obj = stz.localize(date_obj) 38 else:

AttributeError: ‘backports.zoneinfo.ZoneInfo’ object has no attribute ‘localize’

During handling of the above exception, another exception occurred:

Exception Traceback (most recent call last) <ipython-input-26-e0e962df0d1a> in <module> 26 return stories 27 —> 28 df = pd.DataFrame(get_news(‘Banana’))

<ipython-input-26-e0e962df0d1a> in get_news(search) 13 14 for date in date_list[:-1]: —> 15 search = gn.search(search, from_=date.strftime(‘%Y-%m-%d’), to_=(date+delta).strftime(‘%Y-%m-%d’)) 16 newsitem = search[‘entries’] 17

/opt/anaconda3/lib/python3.8/site-packages/pygooglenews/init.py in search(self, query, helper, when, from_, to_, proxies, scraping_bee) 139 140 if from_ and not when: –> 141 from_ = self.from_to_helper(validate=from) 142 query += ’ after:’ + from 143

/opt/anaconda3/lib/python3.8/site-packages/pygooglenews/init.py in __from_to_helper(self, validate) 91 return str(validate) 92 except: —> 93 raise Exception(‘Could not parse your date’) 94 95

Exception: Could not parse your date `

I would appreciate any help

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
KevorkSulahiancommented, Feb 10, 2022

For those who get similar problem. parse_validate has a problem make sure to comment it out, it’s a quick but not optimal solve

1reaction
KevorkSulahiancommented, Jun 8, 2022

@bottaluscio I copied the script and commented out parse_validate part 😃 hope it works for you too

Read more comments on GitHub >

github_iconTop Results From Across the Web

GoogleNews- pygooglenews -Could not parse your date error
Using pygooglenews a month ago and it was working, however now there seems to be an error: Could not parse your date.
Read more >
Could not parse date/time. expected date field to be either a ...
A detailed guide on how to resolve errors related to "could not parse date/time. expected date field to be either a number or...
Read more >
We couldn't parse the input provided as a Date value
I keep getting the error message: Data "Format Error: We couldn't parse the input provided as a Date value". The Query connections seem...
Read more >
Error 'failed to parse date' for Date Time Field with Data Loader
Error 'failed to parse date' for Date Time Field with Data Loader. ... Format the 'Date' and 'Date Time' data in a CSV...
Read more >
jcustenborder/kafka-connect-spooldir - Cannot parse date
I am using v1.0.24 of the library with Kafka connect 4.0.0. I am trying to parse a csv with values: 1,2018-03-12,2018-03-12,1200,A,B ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found