下载文件.py

from selenium import webdriverimport osfp = webdriver.FirefoxProfile()#保存到指定目录:fp.set_preference("browser.download.folderList",2)#是否显示开始、True为显示、false为不显示、fp.set_preference("browser.download.manager.showWhenStarting",False)#指定下载的目录、os.getcwd()返回当期目录、fp.set_preference("browser.download.dir",os.getcwd())#application/octet-stream为文件类型fp.set_preference("browser.helperApps.neverAsk.saveToDisk","application/octet-stream")driver = webdriver.Firefox(firefox_profile=fp)driver.get("http://pypi.Python.org/pypi/selenium")driver.find_element_by_partial_link_text("selenium-2").click()

相关推荐