2016-08-09 2 views
0

ich mit Selen Tor wie mein WebDriver bin mitautomatisch herunterladen Dateien mit Selen und tor

from selenium import webdriver 
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary 

binary = FirefoxBinary('/Applications/TorBrowser.app/Contents/MacOS/firefox') 
driver = webdriver.Firefox(firefox_binary=binary, firefox_profile=profile) 

Es funktioniert genau, wie man sein angenommenes, aber wenn ich versuche, eine Datei herunterzuladen I Standard-Pop aufstehen fragt mich, wo Ich möchte es speichern und so weiter. Ich kann nicht herausfinden, wie ich mit ihnen umgehen soll.

Ich habe zu diesem Thema mehrere Threads gelesen und es scheint, wie

from selenium.webdriver.firefox.firefox_profile import FirefoxProfile 
profile = FirefoxProfile() 
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", 'application/pdf') 
binary = FirefoxBinary('/Applications/TorBrowser.app/Contents/MacOS/firefox') 
driver = webdriver.Firefox(firefox_binary=binary, firefox_profile=profile) 

sollte funktionieren, aber es funktioniert nicht.

Jeder weiß, wie ich

Antwort

0
from selenium import webdriver 
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary 
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile 

profile = profile = FirefoxProfile('/Applications/TorBrowser.app/TorBrowser/Data/Browser/profile.default') 
profile.set_preference("browser.download.manager.showWhenStarting",False) 
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", 'application/pdf') 

binary = FirefoxBinary('/Applications/TorBrowser.app/Contents/MacOS/firefox') 
driver = webdriver.Firefox(firefox_binary=binary,firefox_profile=profile) 

Das

dass Problem lösen funktioniert