hongtaocai / googlefinance

Python module to get real-time stock data from Google Finance API
MIT License
713 stars 170 forks source link

403 Forbidden #44

Open zacscott opened 6 years ago

zacscott commented 6 years ago

I am getting a 403 when using the API, see below;

>>> import googlefinance
>>> googlefinance.getQuotes('GOOGL')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "googlefinance/__init__.py", line 104, in getQuotes
    content = json.loads(request(symbols))
  File "googlefinance/__init__.py", line 47, in request
    resp = urlopen(req)
  File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 435, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 548, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 473, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 556, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: Forbidden

403, looks like Google is blocking bot requests. Visiting in a web browser confirms this - http://finance.google.com/finance/info?client=ig&q=GOOG

screenshot-2018-3-24 sorry

I have tried this on a different computer, on a different network (different IP), same result. I only opened it in Firefox without running Python and it was the same 403 result, so I dont think its just blocking the obvious bot requests.

prakashtewari commented 6 years ago

I am facing the same issue

addisonlynch commented 6 years ago

The Google API is unstable and is no longer officially supported. As such, certain endpoints may return 403s or other errors.