标签: tor-browser-bundle

使用Selenium WebDriver和Tor

因为Tor Browser Bundle只是Firefox的补丁版本,所以似乎应该可以使用FirefoxDriverTor浏览器.这是我到目前为止所尝试的:

String torPath = "C:\\Users\\My User\\Desktop\\Tor Browser\\Start Tor Browser.exe";
String profilePath = "C:\\Users\\My User\\Desktop\\Tor Browser\\Data\\Browser\\profile.default";
FirefoxProfile profile = new FirefoxProfile(new File(profilePath));
FirefoxBinary binary = new FirefoxBinary(new File(torPath));
FirefoxDriver driver = new FirefoxDriver(binary, profile);
driver.get("http://www.google.com");
Run Code Online (Sandbox Code Playgroud)

这会导致打开一个空白的Tor浏览器页面,并显示一条弹出消息:无法加载您的Firefox配置文件.它可能丢失或无法访问.

我知道该配置文件是有效/兼容的,因为我可以成功启动浏览器和配置文件:

binary.startProfile(profile, profilePath, ""));
Run Code Online (Sandbox Code Playgroud)

但是,我不知道如何将命令发送到以这种方式打开的浏览器.

我发现了类似的问题,但我特意寻找Java解决方案,最好在Windows上测试.

我使用的是独立硒库,可以下载在这里和Tor浏览器套件,可以下载在这里.

java firefox tor selenium-webdriver tor-browser-bundle

22
推荐指数
1
解决办法
2万
查看次数