python 后无法从 Quandl 获取数据
Not able to fetch data from Quandl in python
我试过下面的代码(写在文件test.py中):
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 connect@quandl.com.
我该如何前进?
更新:
我也在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 验证码似乎被阻止了(我不确定)。
我认为您需要将您的身份验证令牌传递给它:
quandl.get("EOD/AAPL", authtoken="...")
这是 Apple (AAPL) 的returns收盘价。
如果您在输入 quandl.get("...") 时未获取数据并且显示错误。然后你需要去quandl。在搜索选项中输入 "GOOGLE STOCK"。然后单击您选择的数据集 select。之后转到库并单击 python 并获得类似 quandl.get("....dataset",authtoken="....") 的内容。复制并粘贴到您的命令 shell.
我试过下面的代码(写在文件test.py中):
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 connect@quandl.com.
我该如何前进?
更新: 我也在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 验证码似乎被阻止了(我不确定)。
我认为您需要将您的身份验证令牌传递给它:
quandl.get("EOD/AAPL", authtoken="...")
这是 Apple (AAPL) 的returns收盘价。
如果您在输入 quandl.get("...") 时未获取数据并且显示错误。然后你需要去quandl。在搜索选项中输入 "GOOGLE STOCK"。然后单击您选择的数据集 select。之后转到库并单击 python 并获得类似 quandl.get("....dataset",authtoken="....") 的内容。复制并粘贴到您的命令 shell.