You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from google_alerts import GoogleAlerts
ga = GoogleAlerts(email, password)
ga.authenticate()
ga.list()
I get this output:
←[1;32mDEBUG __init__:_config_bootstrap():156 2021-05-10 18:33:25,930←[0m| Caching authentication in config file
←[1;32mDEBUG __init__:_session_check():185 2021-05-10 18:33:25,930←[0m| Loaded cookies from session file
←[1;32mDEBUG __init__:_process_state():225 2021-05-10 18:33:26,460←[0m| Capturing state from the request
←[1;32mDEBUG __init__:authenticate():291 2021-05-10 18:33:27,202←[0m| [!] User has already authenticated
... and then I get an error about InvalidState. I have already saved my config and seeded my session. I have not added an alert - this is my first time using this API.
How should I get around this error?
The text was updated successfully, but these errors were encountered:
I apologize, this is incredibly late, but in case it helps someone in the future...
This error is occurring because the process_state() function in the __init__.py file is outdated. It's attempting to pull the state from the text of the HTML tag, but Google Alerts interface has changed so that the text of the tag is blank. Instead, you need to pull the state from the property of the tag itself. This requires code changes in the process_state() function.
On line 228, you will see for i in soup.findAll('script'):
Edit this for loop to contain the following:
for i in soup.findAll('script'):
string_i = str(i)
if 'window.STATE' not in string_i:
continue
try:
state = json.loads(string_i[string_i.index('window.STATE') + 13:-15])
if state != "":
self._state = state
self._log.debug("State value set: %s" % self._state)
except Exception as e:
raise StateParseFailure("Google has changed their core protocol and a new parser must be built. Please file a bug at https://github.com/9b/google-alerts/issues.")
For context, this is what the outdated for loop looks like currently:
for i in soup.findAll('script'):
if i.text.find('window.STATE') == -1:
continue
try:
state = json.loads(i.text[25:-6])
if state != "":
self._state = state
self._log.debug("State value set: %s" % self._state)
except Exception as e:
raise StateParseFailure("Google has changed their core protocol and a new parser must be built. Please file a bug at https://github.com/9b/google-alerts/issues.")
OS: Windows 10
Browser: Chrome
Version: 0.2.9
When I run this:
I get this output:
... and then I get an error about InvalidState. I have already saved my config and seeded my session. I have not added an alert - this is my first time using this API.
How should I get around this error?
The text was updated successfully, but these errors were encountered: