2
- 使用Python3来取消网站。使用xpath查询来检索所需的字符串。
- 看起来大约有19个数据应该查询的元素,但dataId变量只能显示一个条目。
- 我也试图获取数据eventid,即在/ tr标记本身(包含图像)。但代码现在似乎排除此html标记
我的理解错了吗?Python3 - 尝试获取数据属性值时,XPath查询不会从站点返回整个列表
import requests
from lxml import etree
url = 'http://www.forexfactory.com/calendar.php?'
date = {'day':'feb9.2017'}
resp = requests.get(url,date)
tree = etree.HTML(resp.text)
dataId = tree.xpath("string(//*[@id='flexBox_flex_calendar_mainCal']//tr[contains(@class,'calendar__row calendar_row')])")
谢谢!这个伎俩 – Karun