久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何使用 Python 通過 Selenium 檢索標(biāo)題屬性?

How to retrieve the title attribute through Selenium using Python?(如何使用 Python 通過 Selenium 檢索標(biāo)題屬性?)
本文介紹了如何使用 Python 通過 Selenium 檢索標(biāo)題屬性?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

這是我的代碼:print(browser.find_element_by_partial_link_text(followers").get_attributes(title")).我正在使用 find_element_by_partial_link_text 因為每個用戶的 xpath 可能是唯一的.但是我的代碼什么也沒返回.這是元素的地址:

This is my code : print(browser.find_element_by_partial_link_text("followers").get_attributes("title")). I am using find_element_by_partial_link_text because maybe the xpath could be unique for each user. But my code returns nothing. This is the element's adress:

<li class=" LH36I">
  <a class=" _81NM2" href="/username/followers/">
    <span class="g47SY lOXF2" title="3,862,378">3.8m</span> 
      " followers"
  </a>
</li>

所以我的問題是如何使用 find_element_by_partial_link_text 獲取標(biāo)題中的值?提前致謝.

So my question is how can i get the value in the title using find_element_by_partial_link_text ? Thanks in advance.

已解決:您可以查看 DebanjanB 的答案.

SOLVED : You can look at DebanjanB 's answer.

推薦答案

title3,862,378 的文本不在任何 <a> 標(biāo)簽.因此你不能使用 find_element_by_partial_link_text().此外,該元素是一個動態(tài)元素,因此您必須為所需的 visibility_of_element_located() 誘導(dǎo) WebDriverWait,您可以使用以下解決方案:

The text of the title i.e. 3,862,378 isn't within any <a> tag. Hence you can't use find_element_by_partial_link_text(). Moreover the element is a dynamic element so so you have to induce WebDriverWait for the desired visibility_of_element_located() and you can use the following solution:

  • 使用 XPATH:

print(WebDriverWait(browser, 20).until(EC.visibility_of_element_located((By.XPATH, "http://a[@href='/username/followers/' and contains(., 'followers')]/span"))).get_attribute("title"))

  • 使用 CSS_SELECTOR:

    print(WebDriverWait(browser, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "a[href='/username/followers/']>span"))).get_attribute("title"))
    

  • 注意:根據(jù)文檔,實際方法是 get_attribute(name) 但不是 get_attributes()

    Note: As per the documentation the actual method is get_attribute(name) but not get_attributes()

    這篇關(guān)于如何使用 Python 通過 Selenium 檢索標(biāo)題屬性?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

    【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

    相關(guān)文檔推薦

    How to draw a rectangle around a region of interest in python(如何在python中的感興趣區(qū)域周圍繪制一個矩形)
    How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
    How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應(yīng)用閾值?)
    How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
    Detect image orientation angle based on text direction(根據(jù)文本方向檢測圖像方向角度)
    Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
    主站蜘蛛池模板: 国产成人久久精品一区二区三区 | 97国产一区二区 | 综合精品久久久 | 午夜欧美 | 欧美日韩久久精品 | 久久成人精品一区二区三区 | 欧美 日韩 在线播放 | 国产乱一区二区三区视频 | 一区二区三区中文字幕 | 色天天综合 | 九九热久久免费视频 | 中日韩欧美一级片 | 免费一级做a爰片久久毛片潮喷 | 欧美亚洲视频 | 成人影视网 | 国产精品99 | www.亚洲国产精品 | 91视频久久久久 | 新av在线| 欧美日韩国产精品一区 | 亚洲风情在线观看 | 久久综合久久久 | sese视频在线观看 | 国产精品乱码一二三区的特点 | 成人三区 | 一区二区三区在线免费观看 | 免费在线一区二区三区 | 亚洲 精品 综合 精品 自拍 | 99re66在线观看精品热 | 久久婷婷国产麻豆91 | 久久综合九色综合欧美狠狠 | 国产区视频在线观看 | 国产亚洲一区二区精品 | 日韩一区中文字幕 | 在线国产视频 | 国产一区精品 | 91亚洲精品国偷拍自产在线观看 | 中文精品久久 | 国产精品久久久久久久久久久免费看 | 亚洲在线成人 | 亚洲一区二区av |