我正在使用以下代码作为代理。但是,当chrome启动时,会弹出一个弹出窗口,并且程序将被锁定。
public async void StartDriver(string proxy)
{
var proxys = new Proxy();
ChromeDriverService chromeDriverService = ChromeDriverService.CreateDefaultService();
chromeDriverService.HideCommandPromptWindow = true;
ChromeOptions chromeOptions = new ChromeOptions();
bool flag = !string.IsNullOrEmpty(proxy);
if (flag)
{
proxys.Kind = ProxyKind.Manual;
proxys.IsAutoDetect = false;
proxys.SslProxy = proxy;
chromeOptions.Proxy = proxys;
}
driver = new ChromeDriver(chromeDriverService, chromeOptions, TimeSpan.FromMinutes(10));
await Task.Delay(2000);
}
我尝试了相同的http或ssl ...
StartDriver("88.55.66.77:8080");
或
StartDriver("http://username:pass@88.55.66.77:8080");
我无法使用某种代理启动浏览器。
我想要一个自动输入用户名和密码的代码。我不要autoitx3.dll。
是否可以启动安全代理?
谢谢。
答案 0 :(得分:1)
是否可以启动安全代理?
有一个。您需要使用代理设置创建chrome扩展程序。
manifest.json
ServerData
background.js
{
"version": "0.1.0",
"manifest_version": 2,
"name": "%NAME IT AS YOU WANT%",
"permissions": [
"proxy",
"tabs",
"unlimitedStorage",
"storage",
"<all_urls>",
"webRequest",
"webRequestBlocking"
],
"background": {
"scripts": ["background.js"]
},
"minimum_chrome_version":"22.0.0"
}
打包为存档。例如 yourExt.dat
//note that it's a JS code. You can use any additional code to do anything :)
var config = {
mode: "fixed_servers",
rules: {
singleProxy: {
scheme: "http",
host: "%HOST%",
port: parseInt(%PORT%)
},
bypassList: ["foobar.com"]
}
};
chrome.proxy.settings.set({value: config, scope: "regular"}, function() {});
function callbackFn(details) {
return {
authCredentials: {
username: "%USERNAME%",
password: "%PASSWORD%"
}
};
}
chrome.webRequest.onAuthRequired.addListener(
callbackFn,
{urls: ["<all_urls>"]},
['blocking']
);