from selenium import webdriver import time import urllib2 class Download(): def __init__(self): self.fp = webdriver.FirefoxProfile() self.fp.set_preference("browser.download.folderList",2) self.fp.set_preference("browser.download.manager.showWhenStarting",False) self.fp.set_preference("browser.download.dir", r"C:\download") self.fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream") def ClickAndDown(self,baseurl,classname): dr = webdriver.Firefox(firefox_profile=self.fp) dr.get(baseurl) time.sleep(10) downbtn = dr.find_element_by_class_name(classname) time.sleep(1) downbtn.click() time.sleep(60) dr.close() dr.quit() dr = None time.sleep(10)