1
因此,我使用硒從網站下載文件,我發出了等待命令35秒(只需要大約10次下載),在文件夾中它放置在哪裏顯示一切正確,但我傳遞文件的名稱作爲我的程序中的參數,我總是得到最後的.part,即使該文件已完全下載並顯示在我的下載文件夾上正確。這裏是我的代碼獲取.part evertime我使用python下載selenium webdriver中的文件
Binary= FirefoxBinary('/home/what/Desktop/firefox/firefox-bin')
profile = webdriver.FirefoxProfile()
profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.download.manager.showWhenStarting", False)
profile.set_preference("browser.download.dir", '/home/jerad/Desktop/Build')
profile.set_preference("browser.helperApps.neverAsk.openFile", "application/octet-
stream")
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/x-gzip")
driver = webdriver.Firefox(firefox_profile=profile, firefox_binary=Binary)
driver.get("website")
driver.find_element_by_xpath("//a[contains(text(), 'DEVcrt.sp1')]").click()
working = "/home/what/Desktop/Build"
abspath = os.path.join(os.getcwd(), working)
for file1 in os.listdir(abspath):
abspath = os.path.join(working, file1)
os.path.isfile(abspath)
time.sleep(35)
print "fnshed downloading"
return abspath
這裏是一個被調用它(的一部分)
j = GetUpdate()
u = jerad.Update()