Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

urllib.error.HTTPError: HTTP Error 999: Request denied #54

Open
sdglobe opened this issue Nov 2, 2017 · 7 comments
Open

urllib.error.HTTPError: HTTP Error 999: Request denied #54

sdglobe opened this issue Nov 2, 2017 · 7 comments

Comments

@sdglobe
Copy link

sdglobe commented Nov 2, 2017

got error trying to run ystockquote.get_price('AAPL') or ystockquote.get_all('AAPL') What is the issue here?

@HenryWan16
Copy link

The same problem

@wawa12
Copy link

wawa12 commented Nov 2, 2017

Looks like Yahoo is shutting down this service. Error message is now: 403 Forbidden It has come to our attention that this service is being used in violation of the Yahoo Terms of Service. As such, the service is being discontinued. For all future markets and equities data research, please refer to finance.yahoo.com

@joeharr4
Copy link

Both Yahoo! and Google have changed or shut down their APIs. Is there another source of data, such as the markets themselves or brokers (at least for their customers)? I see very little discussion of alternatives, but some, such as (scroll down a bit):

https://stackoverflow.com/questions/46080632/http-error-404-from-googlefinance-in-python-2-7/46081537#46081537

--jh--

@7AC
Copy link

7AC commented Nov 11, 2017

Something like this seems to still work, I recently switched from ystockquote to it:

import json
import requests

symbol = 'ANET'
response = requests.get('https://finance.google.com/finance?output=json&q=' + symbol)
# The response is not valid JSON if you don't strip the leading "\n//"
text = response.text.lstrip()[2:]
quote = json.loads(text)

@swoodford
Copy link

+1
I'm seeing a 302 redirect to a dead end:

Traceback (most recent call last):
  File "stockticker-ledboard.py", line 52, in <module>
    allInfo = ystockquote.get_all(tickerSymbol)
  File "/usr/local/lib/python2.7/dist-packages/ystockquote.py", line 47, in get_all
    values = _request(symbol, ids).split(',')
  File "/usr/local/lib/python2.7/dist-packages/ystockquote.py", line 32, 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 437, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 550, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 469, in error
    result = self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 656, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/lib/python2.7/urllib2.py", line 437, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 550, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 469, in error
    result = self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 656, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/lib/python2.7/urllib2.py", line 431, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 449, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1227, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.7/urllib2.py", line 1197, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno -2] Name or service not known>

@Snortfire
Copy link

I found someone on the web did produce a working google query:
https://www.google.com/finance/getprices?q=MKSI&x=NASDAQ&i=60&p=2d&f=d,c,h,l,o,v

URL output to browser looks like this:

EXCHANGE%3DNASDAQ
MARKET_OPEN_MINUTE=570
MARKET_CLOSE_MINUTE=960
INTERVAL=60
COLUMNS=DATE,CLOSE,HIGH,LOW,OPEN,VOLUME
DATA=
TIMEZONE_OFFSET=-240
a1524231000,105.25,105.25,105.2,105.2,25558
1,105.225,105.275,104.65,105.25,20164
2,105.4,105.5,104.75,104.75,4997
....
....

I’m no python coder, but was curious to see where such development is at this point. Happy to hear if this is picked up again.

@Samar-080301
Copy link

Something like this seems to still work, I recently switched from ystockquote to it:

import json
import requests

symbol = 'ANET'
response = requests.get('https://finance.google.com/finance?output=json&q=' + symbol)
# The response is not valid JSON if you don't strip the leading "\n//"
text = response.text.lstrip()[2:]
quote = json.loads(text)

It's returning the google finance webpage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants