【发布时间】:2020-11-26 18:33:56
【问题描述】:
我正在尝试从该费率网站检索数据,但它无法获取任何信息。我已经为不同的网站尝试了相同的格式,但效果很好,所以我不确定这里发生了什么。
import requests
from requests_html import HTMLSession
#get usd to gbp rate
session = HTMLSession()
response = session.get('https://www.xe.com/currencyconverter/convert/?Amount=1&From=USD&To=GBP')
rate = response.html.xpath('//span[@class="converterresult-toAmount"]/*')
print('USD to GBP Rate:',rate)
#(output): USD to GBP Rate: []
【问题讨论】:
-
欢迎来到 Stackoverflow!请注意阅读How to ask a good quetion。您可以通过努力解决问题来改进您的问题,例如通过说明 API 的工作原理以及您如何尝试将代码从站点 A 调整到站点 B。
标签: html python-3.x xpath web-scraping python-requests