无法从python中的Quandl获取数据 [英] Not able to fetch data from Quandl in python

查看:82
本文介绍了无法从python中的Quandl获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了以下代码(写在文件test.py中):

I tried the following code (written in a file 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中尝试过:

UPDATE: I also tried it in 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验证码似乎正在阻止(我不确定).

It seems like the Cloudflare Captcha is blocking (I'm not sure).

推荐答案

我相信您需要将身份验证令牌传递给它:

I believe you need to pass it your authentication token:

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

这将返回苹果(AAPL)的当日价格.

This returns the end of day prices for Apple (AAPL).

这篇关于无法从python中的Quandl获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆