java从Selenium调用Tor的WebDriver
我需要Tor的Webdriver实例才能启动google。selenium的tor中的com,Windows中的java代码,并且能够搜索目标字符串
我的代码在下面
String torPath = "..Installations\\Tor\\Tor Browser\\Browser\\firefox.exe";
String profilePath = "..Installations\\Tor\\TorBrowser\\Browser\\TorBrowser\\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");
这将导致打开一个空白的Tor浏览器页面。它不会加载谷歌。根据需要。我知道配置文件有效/兼容,因为我可以通过以下方式成功启动浏览器和配置文件:
binary.startProfile(profile, profilePath, ""));
我看过类似的问题,但没有得到满意的答案
能做到吗?如果是,怎么做? 我正在寻找Java代码
# 1 楼答案
使用这个代码