[英]Using selenium in python to get data from dynamic website: how to discover the way databases querys are done?
[英]How to get data from a website using python selenium
我正在嘗試從 svg 元素(圖形)中獲取數據。 我使用帶有 name() 功能的 x 路徑,但它仍然返回空字符串..我的 python 代碼是
outer_html_1 = self.driver.find_elements(By.XPATH,"//*[local-name()='svg' and @class='nvd3-svg']//*[local-name()='g' and @class='nvd3 nv-wrap nv-lineChart']//*[local-name()='g' and @class='nv-focus']//*[local-name()='g' and @class='nvd3 nv-wrap nv-line']//*[local-name()='g']//*[local-name()='g' and @class='nv-groups']//*[local-name()='g' and @class='nv-group nv-series-2']//*[local-name()='path' and @class='nv-line']")
print(outer_html_1)
如果我遺漏了什么,請告訴我......我想回答
您可以直接訪問元素並打印文本值(除非它隱藏在 iframe 后面)。
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
data = WebDriverWait(self.driver, 30).until(EC.presence_of_element_located((By.XPATH, "//g/path[@class='nv-line']")))
print(data.get_attribute("d"))
# This should print the value from the attribute "d"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.