我正在使用雅虎财务阅读股票数据到python。它适用于股票,但是它会给商品带来错误。将商品阅读为与雅虎金融的蟒蛇
下面的代码工作完美:
import pandas as pd
import numpy as np
import pandas.io.data as web
import datetime
# We will look at stock prices over the past year, starting at January 1, 2016
start = datetime.datetime(2016,1,1)
end = datetime.date.today()
stock = "AAPL"
# get stock data, from yahoo finance within the dates specified
stock = web.DataReader(stock, "yahoo", start, end)
stock.head(n=3)
但是,如果你改变了手柄商品而不是股票,你得到这个错误:
import pandas as pd
import numpy as np
import pandas.io.data as web
import datetime
# We will look at stock prices over the past year, starting at January 1, 2016
start = datetime.datetime(2016,1,1)
end = datetime.date.today()
stock = "GCG17.CMX"
# get stock data, from yahoo finance within the dates specified
stock = web.DataReader(stock, "yahoo", start, end)
stock.head(n=3)
OSError: after 3 tries, Yahoo! did not return a 200 for url 'http://ichart.finance.yahoo.com/table.csv?s=GCG17.CMX&a=0&b=1&c=1970&d=0&e=22&f=2017&g=d&ignore=.csv'
谁能帮助我?
将此输入到浏览器中,然后您将看到为什么http://ichart.finance.yahoo.com/table.csv?s=GCG17.CMX&a=0&b=1&c=1970&d=0&e=22&f=2017&g=d&ignore=的.csv – e4c5