2017-08-15 118 views
0

從Quandl獲取數據我嘗試下面的代碼(寫在一個文件test.py):不能在python

import pandas as pd 
import quandl 
d=quandl.get('WIKI/PRICES') 

而且我得到這個錯誤信息:

Traceback (most recent call last): 
    File "C:\Python36\lib\site-packages\quandl\connection.py", line 55, in parse 
    return response.json() 
    File "C:\Python36\lib\site-packages\requests\models.py", line 892, in json 
    return complexjson.loads(self.text, **kwargs) 
    File "C:\Python36\lib\json\__init__.py", line 354, in loads 
    return _default_decoder.decode(s) 
    File "C:\Python36\lib\json\decoder.py", line 339, in decode 
    obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 
    File "C:\Python36\lib\json\decoder.py", line 357, in raw_decode 
    raise JSONDecodeError("Expecting value", s, err.value) from None 
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "C:/Users/L.Shane/Desktop/test.py", line 3, in <module> 
    d=quandl.get('WIKI/PRICES') 
    File "C:\Python36\lib\site-packages\quandl\get.py", line 48, in get 
    data = Dataset(dataset_args['code']).data(params=kwargs, handle_column_not_found=True) 
    File "C:\Python36\lib\site-packages\quandl\model\dataset.py", line 47, in data 
    return Data.all(**updated_options) 
    File "C:\Python36\lib\site-packages\quandl\operations\list.py", line 14, in all 
    r = Connection.request('get', path, **options) 
    File "C:\Python36\lib\site-packages\quandl\connection.py", line 36, in request 
    return cls.execute_request(http_verb, abs_url, **options) 
    File "C:\Python36\lib\site-packages\quandl\connection.py", line 44, in execute_request 
    cls.handle_api_error(response) 
    File "C:\Python36\lib\site-packages\quandl\connection.py", line 61, in handle_api_error 
    error_body = cls.parse(resp) 
    File "C:\Python36\lib\site-packages\quandl\connection.py", line 57, in parse 
    raise QuandlError(http_status=response.status_code, http_body=response.text) 
quandl.errors.quandl_error.QuandlError: (Status 403) Something went wrong. Please try again. If you continue to have problems, please contact us at [email protected] 

哪有我前進?

更新: 我也試圖在R:

mydata = Quandl("WIKI/PRICES") 

現在,我得到這個錯誤:

Error: <!DOCTYPE html> 
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]--> 
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en-US"> <![endif]--> 
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en-US"> <![endif]--> 
<!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]--> 
<head> 
<title>Attention Required! | Cloudflare</title> 

<meta charset="UTF-8" /> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" /> 
<meta name="robots" content="noindex, nofollow" /> 
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" /> 
<link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/cf.errors.css" type="text/css" media="screen,projection" /> 
<!--[if lt IE 9]><link rel="stylesheet" id='cf_styles-ie-css' href="/cdn-cgi/styles/cf.errors.ie.css" type="text/css" media="screen,projection" /><![endif]--> 
<style type="text/css">body{margin:0;padd 

這似乎是CloudFlare的驗證碼是阻止(我不知道)。

回答

0

我相信你需要通過它您的身份驗證令牌:

quandl.get("EOD/AAPL", authtoken="...") 

這將返回當日價格爲蘋果(AAPL)結束。

+0

我剛試過,但仍收到相同的信息。 –