Issue
I am working with the following selenium code:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
options=Options()
options.add_argument("--window-size=1920,1080")
driver=webdriver.Chrome(options=options)
driver.get("https://www.ons.gov.uk/")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.NAME, "q"))).send_keys("Education and childcare")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.NAME, "q"))).send_keys("Education and childcare")
click_button=driver.find_element_by_xpath('//*[@id="nav-search-submit"]').click()
click_button=driver.find_element_by_xpath('//*[@id="results"]/div[1]/div[2]/div[1]/h3/a/span').click()
click_button=driver.find_element_by_xpath('//*[@id="main"]/div[2]/div[1]/section/div/div[1]/div/div[2]/h3/a/span').click()
click_button=driver.find_element_by_xpath('//*[@id="main"]/div[2]/div/div[1]/div[2]/p[2]/a').click()
The code goes into an open source data website and downloads a report file. At the moment, the file downloads into the downloads folder. How do I adapt this code so that the downloaded file saves inside a specific location. I'd like the file to download in the following location:
C:\Users\David\Desktop\Downloaded_File
Solution
df1.to_excel('output1.xlsx', engine='xlsxwriter')
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_excel.html
Answered By - user2361290
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.