问题:
我做了什么:
搜索拼写错误。
尝试了不同的公司(例如 REXAHN PHARMACEUTICALS, INC)。
对 Xpath 参数使用了不同的词。
代码:
filing_dates_pg = requests.get('http://csuite.xbrl.us/php/dispatch.php?Task=xbrlValues&Element=NetCashProvidedByUsedInOperatingActivitiesContinuingOperations&CIK=0001228627&Ultimus=true&DimReqd=false&API_Key=xxxx')
# The URL easiest to read in FIREFOX Browser.
Datestree = html.fromstring(filing_dates_pg.text)
date_list = Datestree.xpath('//periodStart/text()')
filing_type_list = Datestree.xpath('//period/text()')
ocf = Datestree.xpath('//amount/text()')
print ocf # Works, list matches data in URL page
print filing_type_list # Works
print type(date_list)
print date_list # Does NOT work
输出
['-2977634', '-4566843', '-5146845', '-6986598', '-53917328', '-2425835', '-55897199', '-7490595', '-57546899', '-10651611', '-58620377', '-15530306', '-60171904', '-1916510', '-62675625', '-3896381', '-64356343', '-5546081', '-66605233', '-6619559', '-69181840', '-1551527', '-4055248', '-5735966', '-7984856', '-11041211', '-2576607', '-4038817', '-5527773', '-8441718', '-8129391', '-12944191']
['1H', '3QCUM', 'Y', 'Y', '2001-03-19 - 2012-04-01', '1Q', '2001-03-19 - 2012-07-01', '1H', '2001-03-19 - 2012-10-01', '3QCUM', '2001-03-19 - 2013-01-01', 'Y', '2001-03-19 - 2013-04-01', '1Q', '2001-03-19 - 2013-07-01', '1H', '2001-03-19 - 2013-10-01', '3QCUM', '2001-03-19 - 2014-01-01', 'Y', '2001-03-19 - 2014-04-01', '1Q', '1H', '3QCUM', 'Y', 'Y', '1Q', '1Q', '1H', '1H', '3QCUM', '3QCUM']
<type 'list'>
[]
ValueError: Length mismatch: Expected axis has 0 elements, new values have 1 elements
我是一名优秀的程序员,十分优秀!