0

我需要解析一个网站,但这个网站有 Windows 身份验证 (kerberos),我HttpRequester通过了身份验证,但如何将身份验证传递给 AngleSharp?

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Credentials = new NetworkCredential("user", "pass");
req.CookieContainer = session;

之后,我不知道如何继续将会话传递给AngleSharp连接:

var configuration = Configuration.Default.WithDefaultLoader().WithCookies();
var context = BrowsingContext.New(configuration);
await context.OpenAsync(WebsiteUrl);
4

1 回答 1

1

您需要 NuGet AngleSharp.Io 包,这将启用“WithRequesters”

接着:

var credentials = new NetworkCredential("user", "pass", "domain");
var handler = new HttpClientHandler { Credentials = credentials };
var config = Configuration.Default.WithRequesters(handler).WithCookies();
var context = BrowsingContext.New(config);
var document = await context.OpenAsync(url)
于 2017-05-11T12:50:52.373 回答