[英]How to download a text file containing data for an interactive barchart but has no URL, just an XPath? Is Selenium a potent solution?
I have scripted a Python code that lets me click on the submit button to make input selections and get their output on a given website.我编写了一个 Python 代码,让我可以点击提交按钮来进行输入选择并在给定的网站上获得它们的输出。 However on the screen, there's an interactive bar chart ie if I move my mouse over it and click on the bars, I can see values that constitute that column.
但是在屏幕上,有一个交互式条形图,即如果我将鼠标移到它上面并单击条形图,我可以看到构成该列的值。
I need to download the underlying data for this bar chart and if I right-click on the bar chart and click save as it downloads me a nice .txt file which contains an unstructured table for this bar chart.我需要下载此条形图的基础数据,如果我右键单击条形图并单击“保存”,它会为我下载一个不错的 .txt 文件,其中包含此条形图的非结构化表格。
However, how do I automate the process of downloading these text files corresponding to each bar chart (there are 80 in all) to a specific directory assuming that I am using Python, Selenium and Mozilla Firefox?但是,假设我使用的是 Python、Selenium 和 Mozilla Firefox,我如何自动将与每个条形图(总共有 80 个)对应的这些文本文件下载到特定目录的过程?
You can use context_click method from ActionChains to right click on your element.您可以在元素上使用来自ActionChains context_click方法点击右键。
from selenium import webdriver
from selenium.webdriver import ActionChains
driver = webdriver.Chrome()
actionChains = ActionChains(driver)
actionChains.context_click(your_link).perform()
drivers.find_elements_by_xpath(path_of_the_download_option)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.