雅虎财务API问题

时间:2017-05-08 22:25:24

标签: urllib2 yahoo-finance http-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

我正在做的就是从API访问历史数据。还有其他人有这个问题吗?问题实际上是在Yahoo服务器上吗?我是否有可能发送太多请求(要求提供100种股票的历史数据)?

1 个答案:

答案 0 :(得分:0)

我也有同样的问题。我正在使用此查询:

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=

我正在使用

>  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

我可以看到我得到了 远程服务器返回错误:(500)内部服务器错误 在一些股票上,但并不总是相同的。我一次得到大约40种股票的股票价格。 Yahoo Finance对此查询的每小时限制为2000个请求,如果超过该请求,则错误输出403错误,因此我认为过度使用不会导致500错误。我在围绕objWebRequest.GetResponse的代码中使用了Try,Catch。