Python 2 v. 3 xpath

岁酱吖の 提交于 2019-12-25 08:48:19

问题


This code returns one element under Python 2.7.9 and no elements under 3.4.3. Why? How do I fix it for Python 3?

import requests
from lxml import html

page = requests.get('http://www.bloomberg.com/markets/rates-bonds/government-bonds/us/').text
tree = html.fromstring(page)

line = tree.xpath('//table[@class="std_table_module dual_border_data_table clear"][2]')
print(line)

来源:https://stackoverflow.com/questions/28766281/python-2-v-3-xpath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!