I need to go to this website and click on a link. After clicking on the link, a file automatically gets downloaded. I'm not sure how frequent the update to the file is, but I need this automated. I know I can fire up a task scheduler and click on the link daily and overwrite the previous file on my current working directory. But is there anyway for me to actually check the size of the file before download commences? If the file size is greater than my file on the directory, then download, otherwise don't download?
I have this so far:
from selenium import webdriver
import os
chromeOptions = webdriver.ChromeOptions()
prefs = {'download.dafault_directory' : os.getcwd()}
chromeOptions.add_experimental_option('prefs',prefs)
chromedriver = 'H://work/chromedriver.exe'
driver = webdriver.Chrome(chrome driver,chrome_options=chromeOptions)
#website where we download files from
url = 'https://supplier.bge.com/electric/load/profiles.asp'
driver.get(url)
driver.implictly_wait(5)
link = driver.find_element_by_link_text('Historical Hourly Load Data')
link.click()
This works. But as I mentioned before, I'm not sure when the next update is. I just wanted to know if there was a more pythonic way of checking file size against the file I have currently in my working directory and if the file size is greater than what I have, then download, otherwise don't download.