Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bulk download option #14

Open
monomeric opened this issue Mar 23, 2020 · 1 comment
Open

Add bulk download option #14

monomeric opened this issue Mar 23, 2020 · 1 comment

Comments

@monomeric
Copy link

Would it be possible to add an option to download the bulk file, as when clicking "Download" on the bottom right of the browser, as well as the Acknowledgement Table?

Otherwise: Thanks for this truly useful package!

@monomeric
Copy link
Author

Fixed the above by modifying gisaid-scrapper.py. Perhaps this is of use for someone else as well.

Added a profile to the firefox session:

profile = webdriver.FirefoxProfile()
profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.download.manager.showWhenStarting", False)
profile.set_preference("browser.download.dir","~")
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/csv,application/download,application/excel,application/msword,application/octet-stream,application/pdf,application/ris,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/x-zip,application/x-zip-compressed,application/zip,image/png,text/csv,text/html,text/plain")
self.driver = webdriver.Firefox(options=options,firefox_profile=profile)

Added simple functions for the bulk download:

def bulk_download(self):
    time.sleep(2)
    self._bulk_download_data()
    time.sleep(2)
    self._bulk_download_acknowledgements()
    time.sleep(30)
    self.driver.quit()

def _bulk_download_data(self):
    #self.driver.execute_script(
    #    "document.getElementById('sys_curtain').remove()")
    self.driver.find_elements_by_tag_name("button")[3].click()

def _bulk_download_acknowledgements(self):
    self.driver.execute_script(
        "document.getElementById('sys_curtain').remove()")
    self.driver.find_elements_by_link_text("here")[0].click()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant