From ba6782d85aadb72e3926635d39b6cf98a95deb91 Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Thu, 14 Feb 2019 12:25:51 +1100 Subject: [PATCH] Use Firefox, and specify download location --- waternsw_grabber/waternsw_grabber.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/waternsw_grabber/waternsw_grabber.py b/waternsw_grabber/waternsw_grabber.py index d5e3eea..a83bdaa 100644 --- a/waternsw_grabber/waternsw_grabber.py +++ b/waternsw_grabber/waternsw_grabber.py @@ -115,13 +115,23 @@ def get_telemetered_bore(driver, bore_id, start_date, end_date): webdriver.ActionChains(driver).send_keys(Keys.ESCAPE).perform() -def open_browser(): +def open_browser(download_dir): # Warn if user does not have admin privileges if not has_admin(): warnings.warn('This program should be run as an administrator.') + profile = webdriver.FirefoxProfile() + profile.set_preference('browser.download.folderList', 2) + profile.set_preference('browser.download.manager.showWhenStarting', False) + profile.set_preference('browser.download.dir', download_dir) + profile.set_preference('browser.helperApps.neverAsk.saveToDisk', + ('application/zip,' + 'application/octet-stream,' + 'application/x-zip-compressed,' + 'multipart/x-zip')) + # Open browser - driver = webdriver.Chrome() + driver = webdriver.Firefox(firefox_profile=profile) url = 'https://realtimedata.waternsw.com.au/water.stm' driver.get(url) @@ -147,6 +157,3 @@ def main(): get_telemetered_bore(driver, bore_id, start_date, end_date) driver.quit() - - -main()