python - downloading file using selenium -


i working on python , selenium. want download file clicking event using selenium. wrote following code.

from selenium import webdriver selenium.common.exceptions import nosuchelementexception selenium.webdriver.common.keys import keys  browser = webdriver.firefox() browser.get("http://www.drugcite.com/?q=actimmune")  browser.close() 

i want download both files links name "export data" given url. how can achieve works click event only.

thanks

find link using find_element(s)_by_*, call click method.

from selenium import webdriver  # prevent download dialog profile = webdriver.firefoxprofile() profile.set_preference('browser.download.folderlist', 2) # custom location profile.set_preference('browser.download.manager.showwhenstarting', false) profile.set_preference('browser.download.dir', '/tmp') profile.set_preference('browser.helperapps.neverask.savetodisk', 'text/csv')  browser = webdriver.firefox(profile) browser.get("http://www.drugcite.com/?q=actimmune")  browser.find_element_by_id('exportpt').click() browser.find_element_by_id('exporthlgt').click() 

added profile manipulation code prevent download dialog.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -