PythonNovice
PythonNovice

Reputation: 11

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. However on the screen, there's an interactive bar chart i.e. 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.

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?

Upvotes: 1

Views: 99

Answers (1)

NitishKshirsagar
NitishKshirsagar

Reputation: 91

You can use context_click method from ActionChains to right click on your element.

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)

Upvotes: 1

Related Questions