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

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

使用python selenium從HTML標(biāo)簽中提取占位符

使用python selenium從HTML標(biāo)簽中提取占位符

UYOU 2021-09-14 20:27:09
我正在使用以下 python 代碼來啟動 Firefox 網(wǎng)頁。from selenium import webdriverfrom selenium.webdriver.common.keys import Keysdriver= webdriver.Firefox()driver.get("https://www.quora.com")啟動后,如果我知道這個(gè)標(biāo)簽的 xpath。<input  class="text header_login_text_box ignore_interaction" type="text" name="email" tabindex="1"data-group="js-editable"placeholder="Email"w2cid="wZgD2YHa18" id="__w2_wZgD2YHa18_email">如果我現(xiàn)在是屬性的名稱,我可以使用以下命令在 python 上使用 selenium webdriver 提取屬性。dict['attribute'] = driver.find_element_by_xpath(x_path).get_attribute(attribute)所以我的輸出將是dict = { 'attribute':value}請幫助我找出提取所有屬性及其值的方法,即使我不知道它具有的所有屬性是什么。我的預(yù)期輸出是dict = { "class" : "text header_login_text_box ignore_interaction"         "type" : "text"         "name":"email"          "tabindex" : "1"        "data-group" : "js-editable"        "placeholder" : "Email"        "w2cid" : "wZgD2YHa18"         "id" : "__w2_wZgD2YHa18_email"        }我不確定這有多大可能,但我希望像在字典中一樣,即使不知道密鑰,我們也可以提取數(shù)據(jù)。謝謝
查看完整描述

3 回答

?
Smart貓小萌

TA貢獻(xiàn)1911條經(jīng)驗(yàn) 獲得超7個(gè)贊

獲取placeholder屬性使用get_attribute()

element.get_attribute('placeholder')


查看完整回答
反對 回復(fù) 2021-09-14
?
qq_遁去的一_1

TA貢獻(xiàn)1725條經(jīng)驗(yàn) 獲得超8個(gè)贊

定義要提取占位符的輸入標(biāo)簽的 xpath。


xpath_input = "//input[@id='__w2_wZgD2YHa18_email']"

driver.find_element_by_xpath(xpath_input)

獲取元素后,您可以通過以下方式提取placeholder(“電子郵件”)get_attribute("placeholder")


查看完整回答
反對 回復(fù) 2021-09-14
  • 3 回答
  • 0 關(guān)注
  • 411 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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