Not able to fetch data from Quandl in python

孤人 提交于 2019-12-13 03:19:29

问题


I tried the following code (written in a file test.py):

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

And I got this error message:

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.

How can I move forward?

UPDATE: I also tried it in R:

 mydata = Quandl("WIKI/PRICES")

Now I got this error:

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

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


回答1:


I believe you need to pass it your authentication token:

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

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



来源:https://stackoverflow.com/questions/45697169/not-able-to-fetch-data-from-quandl-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!