从XPath表达式提取文本内容时出现问题

2024-06-16 18:37:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用以下代码从XPath表达式中提取文本内容:

page = requests.get('https://www.momondo.com/flight-search/PHL-VCE/2019-06-19-flexible/2019-06-25-flexible?sort=price_a')
tree = html.fromstring(page.content)
price = tree.xpath('//span[@class="title price"]/text()')
print(price)

然而,打印的结果只是:[]

我做错什么了吗


Tags: 代码https文本comtree内容get表达式