[英]How to set proxy for Chromium on Windows with Playwright Java?
我用 1.22.0 版本對此進行了測試,它可以工作:
package test;
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserType;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
import com.microsoft.playwright.options.Proxy;
public class Example {
public static void main(String[] args) {
try (Playwright playwright = Playwright.create()) {
BrowserType.LaunchOptions launchOptions = new BrowserType.LaunchOptions();
launchOptions.headless = false;
launchOptions.setProxy(new Proxy("localhost:8888"));
Browser browser = playwright.chromium().launch(launchOptions);
Page page = browser.newPage();
page.navigate("http://playwright.dev");
System.out.println(page.title());
}
}
}
launchOptions 不會導致設置系統代理設置。 您的屏幕截圖上的值必須是之前輸入的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.