【发布时间】:2015-02-26 09:41:40
【问题描述】:
在开始之前,我只想说,我对通过代码与 Web 进行一般通信非常陌生。话虽如此,谁能帮我获取这些参数,
'a': stMonth,
'b': stDate,
'c': stYear,
'd': enMonth,
'e': enDate,
'f': enYear,
'submit': 'submit'
用于此页面上的“设置日期范围”框, http://finance.yahoo.com/q/hp?s=gspc&a=00&b=3&c=1951&d=11&e=29&f=2014&g=d&z=66&y=0
,在我的 Python 代码中工作。它目前包括:
def getHistoricData(symbol, stMonth, stDate, stYear, enMonth, enDate, enYear):
url = 'http://finance.yahoo.com/q/hp?s=%s&a=00&b=3&c=1951&d=11&e=29&f=2014&g=d&z=66&y=0' % symbol
params = {
'a': stMonth,
'b': stDate,
'c': stYear,
'd': enMonth,
'e': enDate,
'f': enYear,
'submit': 'submit',
}
response = requests.get(url, params=params)
tree = html.document_fromstring(response.content)
symbol = raw_input("Symbol: ")
getHistoricData(symbol, '00', '11', '2010', '00', '13', '2010')
我认为参数的名称或值可能有问题,但我不能确定。在此先感谢 - 非常感谢任何和所有帮助! (包括批评,只要它至少有点建设性!)
【问题讨论】:
标签: python html request lxml lxml.html