[英]scrape odds using selenium in python
我想用 Chrome 驅動程序在 Python 中使用 Selenium 刮掉這個頁面
我只對 Bet365 的開盤賠率感興趣。
bet365_row = driver.find_element_by_xpath("//div[@id='odds-content']").find_element_by_tag_name('tbody').find_element_by_xpath("//tr[@data-bid='16']")
odd1= driver.find_element_by_xpath("//tr[@data-originid='1']").find_element_by_xpath("//td[@class='table-main__detail-odds table-main__detail-odds--first']").find_element_by_xpath("//span[@class='table-main__detail-odds--hasarchive']").text
print(odd1)
我寫了這行代碼,但我只能在 10Bet 行上刮掉表的第一個奇數,但希望在 bet365 行上的開盤奇數。
您可以找到表中的所有行,然后測試其中行有 bet365:
trs = browser.find_elements_by_xpath(".//div[@id='odds-content']/div/div/table/tbody/*")
for tr in trs:
if "bet365" in tr.text:
print(tr.text)
# Do whatever you want
完美它的工作原理。 我會通過提取開盤賠率來改進
for tr in trs:
if "bet365" in tr.text:
odd = driver.find_elements_by_class_name('data-opening-odd').text()
print(odd)
但我收到此錯誤 AttributeError: 'list' object has no attribute 'text'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.