Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python\u Selenium如何从图形工具提示中获取文本?_Python_Selenium_Selenium Webdriver_Xpath - Fatal编程技术网

Python\u Selenium如何从图形工具提示中获取文本?

Python\u Selenium如何从图形工具提示中获取文本?,python,selenium,selenium-webdriver,xpath,Python,Selenium,Selenium Webdriver,Xpath,我想保存我所附图片中图形内部的工具提示中的数据。要获取图像,请转到“https://www.plus500.it/Instruments/TSLA单击图表下方的1d和烛台按钮。 我在这里看到了很多示例,但是工具提示没有通过工具提示名称或xpath来标识(我在调试模式下也找不到web元素)。我附加了python脚本 from selenium import webdriver from selenium.webdriver import ActionChains from selenium.we

我想保存我所附图片中图形内部的工具提示中的数据。要获取图像,请转到“https://www.plus500.it/Instruments/TSLA单击图表下方的1d和烛台按钮。

我在这里看到了很多示例,但是工具提示没有通过工具提示名称或xpath来标识(我在调试模式下也找不到web元素)。我附加了python脚本

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time


PATH="C:\Program Files (x86)\chromedriver.exe"
driver= webdriver.Chrome(PATH)

driver.get("https://www.plus500.it/Instruments/TSLA")
driver.maximize_window()
toolTip = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "insert the xpath of the graph")))
hov = ActionChains(driver).move_to_element(toolTip)
txt = hov.perform()
tooltipText = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "insert the     xpath of data"))).text
print(tooltipText)


我也做过类似的事情,但selenium的问题(至少据我所知)是,您无法删除JS other生成的数据,然后在这些数据上使用JS。更具体地说,您需要执行JS代码来完成这项工作。。。可悲的是,我认为你想玩文本,这是一种不幸。。。我向谷歌推荐“使用selenium动态内容抓取”。也许有人会帮你更多,但遗憾的是,我认为没有更好的办法了。祝你的项目好运,我希望它能圆满结束:)