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

如何使用 Python 通過 Selenium 檢索標題屬性?

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

問題描述

這是我的代碼: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 獲取標題中的值?提前致謝.

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> 標簽.因此你不能使用 find_element_by_partial_link_text().此外,該元素是一個動態元素,因此您必須為所需的 visibility_of_element_located() 誘導 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"))
    

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

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

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

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

    相關文檔推薦

    How to draw a rectangle around a region of interest in python(如何在python中的感興趣區域周圍繪制一個矩形)
    How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
    How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應用閾值?)
    How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
    Detect image orientation angle based on text direction(根據文本方向檢測圖像方向角度)
    Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
    主站蜘蛛池模板: 日韩精品久久久久久久酒店 | 久久视频一区 | 黄色大片在线播放 | 丰满少妇av | 少妇一级淫片免费看 | 久久免费小视频 | 国产一级黄色 | 神马午夜影院 | 中文字幕免费看 | 免费av在线 | www.欧美精品 | 欧美爱爱视频 | 国产一级片视频 | 欧美日本精品 | 手机av在线免费观看 | 黄色网在线 | 在线免费播放av | 麻豆av在线免费观看 | 成人a视频 | 午夜国产福利 | 国产福利视频在线观看 | 一级做a视频 | 亚洲欧美日韩国产精品 | 九九九视频| 成人免费看片在线观看 | 国产精品三级在线 | 波多野结衣乳巨码无在线观看 | 一级片观看 | 国产日韩欧美日韩大片 | 久久黄网| 谁有毛片网址 | av一二三区 | 麻豆91在线 | 在线观看黄色小说 | 91小视频在线观看 | 精品三级在线观看 | 午夜视频免费观看 | 亚洲视频免费 | 欧美成视频 | 日本免费一级片 | 日韩精品免费在线观看 |