this code not work yahoo finance of google finance works 'http://www.bloomberg.com/markets/currencies/cross-rates'
import pandas pd lxml.html import parse urllib2 import urlopen pandas.io.parsers import textparser def _unpack(row, kind='td'): elts = row.findall('.//%s' % kind) return [val.text_content() val in elts] def parse_options_data(table): rows = table.findall('.//tr') header = _unpack(rows[0], kind='th') data = [_unpack(r) r in rows[1:]] return textparser(data, names=header).get_chunk() parsed = parse(urlopen('https://www.google.com/finance/option_chain?q=aapl&ouput')) doc = parsed.getroot() tables = doc.findall('.//table') table = parse_options_data(tables[1]) table
how fix?
Comments
Post a Comment