【发布时间】:2016-01-27 17:19:27
【问题描述】:
我试过了,但结果空白
import requests
from lxml import html
response=requests.get('http://www.convertit.com/Go/ConvertIt/Currency/Convert_All_Output.ASP?FCu=USD')
tree = html.fromstring(response.text)
print (tree.xpath('//div/table/tbody/tr[41]/td[1]/text()'))
【问题讨论】:
-
使用与 selenium 相同的代码,但 lxml 显示空白结果。
-
因为表中没有任何 tbody。查看文档来源
-
Selenium 有一个浏览器在后台修复您的 html/xml。你真的很可能想要BeautifulSoup,除非它实际上保证是一个xml文件。