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