GeneralMills / pytrends

Pseudo API for Google Trends
Other
3.2k stars 813 forks source link

Problem with connect #3

Closed PMassicotte closed 9 years ago

PMassicotte commented 9 years ago

Hi there.

I'm trying to use your script. However, when trying to log with my credentials I got the following message.

"connector = pyGTrends(google_username, google_password) Traceback (most recent call last): File "", line 1, in File "/home/persican/Downloads/pytrends-master/pyGTrends.py", line 37, in init self._connect() File "/home/persican/Downloads/pytrends-master/pyGTrends.py", line 64, in _connect self.opener.open(self.url_CookieCheck) File "/usr/lib/python3.4/urllib/request.py", line 461, in open response = meth(req, response) File "/usr/lib/python3.4/urllib/request.py", line 571, in http_response 'http', request, response, code, msg, hdrs) File "/usr/lib/python3.4/urllib/request.py", line 493, in error result = self._call_chain(_args) File "/usr/lib/python3.4/urllib/request.py", line 433, in _call_chain result = func(_args) File "/usr/lib/python3.4/urllib/request.py", line 676, in http_error_302 return self.parent.open(new, timeout=req.timeout) File "/usr/lib/python3.4/urllib/request.py", line 461, in open response = meth(req, response) File "/usr/lib/python3.4/urllib/request.py", line 571, in http_response 'http', request, response, code, msg, hdrs) File "/usr/lib/python3.4/urllib/request.py", line 499, in error return self._call_chain(_args) File "/usr/lib/python3.4/urllib/request.py", line 433, in _call_chain result = func(_args) File "/usr/lib/python3.4/urllib/request.py", line 579, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 400: Bad Request "

Do you have an idea?

Reagrds, Phil

mfine15 commented 9 years ago

Are you able to share your parameters? I'm guessing something isn't formatting right.

dreyco676 commented 9 years ago

Are you able to share your parameters? I bet something isn't formatting right.

Crebit commented 8 years ago

I believe I had a similar issue as PMassicotte. In my case it was caused by Google preventing me to log in without first proving who I was.

Long story short: I created an alter ego gmail to test this fantastic library at work. The work computer, however, routes all internet traffic through our HQ in a different country. Therefore, Google thought that the account was created in that country.

When I tested the library again on my home computer the code stopped working and I got the error message above. I then tried to log in manually (by point and click) and noticed that Google prevented the login because it had noticed my suspicious activity of logging in "in two different countries" within a couple of hours.

I then had to answer a questionnaire where I told where I normally log in and type in the usual unreadable "bot prevention" numbers. After that I could log in normally and the code started to work.

I know this answer is very specific and not at all technical, but hopefully it will help you guys solve the problem.

Kindly, Crebit