10
我的python應用程序使用Selenium Webdriver在幾個小時的工作時間內或多或少地加載了20000頁的網頁。我的問題是「東西」會創建大量的tmp文件,填滿我的所有硬盤。例如,今天早上應用程序在6個小時的工作中生成了70GB的tmp文件:(在重新啓動Ubuntu後,所有這些文件都沒有了,我認爲是Firefox的負責人)Python Firefox Webdriver tmp文件
這種情況發生在Linux和OS X上。
def launchSelenium (url):
profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", "127.0.0.1")
profile.set_preference("network.proxy.http_port", 8080)
profile.set_preference("webdriver.load.strategy", "fast")
profile.set_preference("permissions.default.stylesheet", 2)
profile.set_preference("permissions.default.images", 2)
profile.set_preference("dom.ipc.plugins.enabled.libflashplayer.so", "false")
profile.set_preference("browser.sessionstore.enabled", "false")
profile.set_preference("browser.cache.disk.enable", "false")
profile.update_preferences()
driver = webdriver.Firefox(firefox_profile=profile)
driver.get(url)
try:
element = driver.find_element_by_xpath("//button[@title='Statistics']").click()
except NoSuchElementException:
print "Not available"
driver.close()
return 0
driver.close()
return 1
我加在Firefox配置文件的最後兩首試圖解決這個問題,但沒有任何改變。
難道我做錯了嗎?有在硒的錯誤嗎? 感謝
你的屁股得救了!感謝:^) –
這只是爲我節省了幾個小時的谷歌搜索。謝謝。 – bbenne10
您剛解決了一個問題,需要我花兩天時間才能分離出來 – chasmani