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)
        

  

posted on 2015-08-13 14:40  小白闯天下  阅读(656)  评论(0编辑  收藏  举报