第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

python selenium 抓取包含部分文本的項目

python selenium 抓取包含部分文本的項目

慕慕森 2022-06-07 16:56:59
我想從 html 表中提取特定元素,這是我當(dāng)前的代碼:tabela  = soup.find("div", {"class" : "productDatatable"})>>> tabela<div class="productDatatable">\n<div>\r\n            Category:\r\n                        <span class="productDatatableValue">\n<a href="/en/market/mt5/utility">Utilities</a>\n</span>\n</div>\n<div title="Number of activations available for the buyers of this application. During the activation, software product is bound to the buyer's hardware, so that the copy of the application cannot work on another PC. The application should be re-activated and downloaded again in order to launch it on another computer. If the activation limit is exceeded, the buyer will have to purchase the product again.">\r\n            Activations:\r\n                        <span class="productDatatableValue">\r\n                            5\r\n                        </span>\n</div>\n<div style="padding:5px;"></div>\n<div>\r\n            Author:\r\n                        <span class="productDatatableValue">\n<span style="display: inline-block; vertical-align: middle; margin-top: -2px;"><span class="icoVerified small" title="Verified User"></span></span>\n<span title="Konstantin Chernov"><a class="author" href="/en/users/konstantin83" title="Konstantin83">Konstantin Chernov</a></span>\n</span>\n</div>\n<div>\r\n            Published:\r\n                        <span class="productDatatableValue">\r\n                            16 January 2013\r\n                        </span>\n</div>\n<div>\r\n            Current version:\r\n                        <span class="productDatatableValue">1.55</span>\n</div>\n<div>\r\n            Updated:\r\n                        <span class="productDatatableValue">\r\n                            23 March 2015\r\n                        </span>\n</div>\n</div>我如何從這個 html 輸出中提取類別名稱。我試過這個,但不工作。tabela.find_element_by_xpath("//*[contains(text(), 'Category')]").find("span", {"class" : "productDatatable"}).text我如何從這個 html 中獲取類別?我需要輸出Utilities
查看完整描述

2 回答

?
慕運(yùn)維8079593

TA貢獻(xiàn)1876條經(jīng)驗 獲得超5個贊

要返回Utilities錨標(biāo)簽內(nèi)的內(nèi)容,而不是跨度。嘗試下面的 Beautifulsoup 代碼。 編輯:


from bs4 import BeautifulSoup

import requests

response=requests.get("https://www.mql5.com/en/market/product/635").text

soup=BeautifulSoup(response,'html.parser')

tabela  = soup.find("div", class_="productDatatable").find('span', class_="productDatatableValue").find('a')

print(tabela.text)

編輯:


如果您想使用 selenium,請使用以下 xpath 并參考類別


print(browser.find_element_by_xpath("//div[contains(.,'Category')]/span[@class='productDatatableValue']/a").text)


查看完整回答
反對 回復(fù) 2022-06-07
?
四季花海

TA貢獻(xiàn)1811條經(jīng)驗 獲得超5個贊

請試試這個

tabela.find_element_by_xpath("/html/body/div[1]/div[3]/div[2]/div[1]/div[2]/div[4]/div[1]/span/a").text



查看完整回答
反對 回復(fù) 2022-06-07
  • 2 回答
  • 0 關(guān)注
  • 179 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號