Last active
December 4, 2016 14:41
-
-
Save ryansmccoy/8cc82de3b0008954bbb71e5f96b03678 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# r'https://pypi.python.org/pypi/selenium | |
#from bs4 import BeautifulSoup | |
from selenium import webdriver | |
import os, time, errno, sys | |
#import lxml | |
def main(): | |
if len(sys.argv) < 2: | |
sys.exit(0) | |
else: | |
#url = r'https://www.esios.ree.es/en/analysis/600?vis=1&start_date=04-12-2016T00%3A00&end_date=04-12-2016T23%3A00&compare_start_date=03-12-2016T00%3A00&groupby=hour' | |
url = sys.argv[1] | |
w = webdriver.Chrome() | |
w.get(url) | |
#soup = BeautifulSoup(w.page_source, "lxml") | |
time.sleep(5) | |
#soup.prettify | |
# click the export button using xpath | |
xpath_export = r'//*[@id="dashboardView"]/form/div[7]/div' | |
w.find_element_by_xpath(xpath_export).click() | |
# click the csv button using xpath | |
xpath_export_csv = '//*[@id="dashboardView"]/form/div[7]/div/ul/li[1]/a' | |
w.find_element_by_xpath(xpath_export_csv).click() | |
if __name__ == '__main__': | |
# python selium_click_export_csv.py 'url of webpage' | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment