Search code examples
urllib2yahoo-financehttp-error

Yahoo Finance API Problems


My code was working fine a few days ago but since Friday, I have been getting the following error:

 File "C:\Python27\Lib\urllib2.py", line 527, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
 urllib2.HTTPError: HTTP Error 500: Server Error

All I'm doing is accessing the historical data from the API. Is anyone else having this problem? Is the problem actually on the Yahoo servers? Is there a possibility that I'm sending too many requests (asking for historical data of 100 stocks)?


Solution

  • I am also having the same issue. I am using this query:

    https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quote%20where%20symbol%20in%20(%22APPL%22)&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=
    

    I am using

    >  Try
    >        
    >         objWebRequest = CType(System.Net.WebRequest.Create(strScrapeString),
    > System.Net.HttpWebRequest)
    >         objWebRequest.KeepAlive = False
    >         objWebRequest.Method = "GET"
    >         **objWebResponse = CType(objWebRequest.GetResponse(), System.Net.HttpWebResponse)** *(this is where it fails on debug)*
    > 
    > 
    > ...
    >             
    >             objWebResponse.Close()
    >          
    > 
    >             Return strStockPrice
    > 
    >         Catch ex As Exception
    >             strResults = strResults + "<br/>" + "**ERROR**" + strSymbol + " Yahoo data not available.  Exception Error Message : " +
    > ex.Message.ToString()
    >         End Try
    

    I can see that I am getting the The remote server returned an error: (500) Internal Server Error on some stocks, but it isn't always the same ones. I am getting stock prices for about 40 stocks at a time. Yahoo Finance has a limit of 2000 requests per hour for this query and if you exceed that it should error out with 403 error, so I do not think overuse is the cause of the 500 error. I am using a Try, Catch in my code around the objWebRequest.GetResponse.