
将答案基于@hoju:
import lxml.htmlimport calendarfrom datetime import datetimeexDate = "2014-11-22"symbol = "LLY"dt = datetime.strptime(exDate, '%Y-%m-%d')ym = calendar.timegm(dt.utctimetuple())url = 'http://finance.yahoo.com/q/op?s=%s&date=%s' % (symbol, ym,)doc = lxml.html.parse(url)table = doc.xpath('//table[@]/tbody/tr')rows = [] for tr in table: d = [td.text_content().strip().replace(',','') for td in tr.xpath('./td')] rows.append(d)print rows欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)