Skip to content

Commit

Permalink
Fixed an issue where additional whitespace was causing the Google aut…
Browse files Browse the repository at this point in the history
…hentication to fail.
  • Loading branch information
jdmunro committed Aug 15, 2012
1 parent dacf6d1 commit d2dff6f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pyGTrends.py
Expand Up @@ -51,6 +51,8 @@ def _connect(self):
galx = re.compile('<input type="hidden" name="GALX" value="(?P<galx>[a-zA-Z0-9_-]+)">') galx = re.compile('<input type="hidden" name="GALX" value="(?P<galx>[a-zA-Z0-9_-]+)">')


resp = self.opener.open(self.url_ServiceLoginBoxAuth).read() resp = self.opener.open(self.url_ServiceLoginBoxAuth).read()
resp = re.sub(r'\s\s+', ' ', resp)

m = galx.search(resp) m = galx.search(resp)
if not m: if not m:
raise Exception("Cannot parse GALX out of login page") raise Exception("Cannot parse GALX out of login page")
Expand Down

3 comments on commit d2dff6f

@osmosis79
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After I add your fix, it moves to this next error.

Traceback (most recent call last):
File "test.py", line 5, in
print connector.csv()
File "pyGTrends.py", line 105, in csv
raise Exception("Could not find requested section")
Exception: Could not find requested section

If I check the output of self.raw_data I find
��You must be signed in to export data from Google Trends

update: The cause appears to be the use of google 2-step authentication. Disabled that and pyGTrends.py works.

@dangayle
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix works for me. I was having the same error.

@rnorberg
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting the same error, even with the 2 step authentication disabled. "Could not find requested section"

Please sign in to comment.