我正在使用雅虎財務閱讀股票數據到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