import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class proxyTest {
public static void main(String[] args) {
Proxy proxy = new Proxy();
proxy.setHttpProxy("<HOST:PORT>");
ChromeOptions options = new ChromeOptions();
options.setCapability("proxy", proxy);
WebDriver driver = new ChromeDriver(options);
driver.get("https://www.google.com/");
driver.manage().window().maximize();
driver.quit();
}
}
java中selenium设置http代理
最新推荐文章于 2025-05-25 09:48:00 发布
本文介绍如何使用Java和Selenium WebDriver库配合代理服务器访问网站。通过设置ChromeDriver的代理参数,可以绕过网络限制,实现对特定站点的访问。示例代码展示了配置代理并打开Google主页的过程。
4043

被折叠的 条评论
为什么被折叠?



