2017-01-16 79 views
0

我需要解析一個網站,但是這個有Windows身份驗證(kerberos),我使用HttpRequester進行了身份驗證,但是如何將身份驗證傳遞給AngleSharp?以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); 
+0

這個問題有點寬泛的StackOverflow的備考噸。你能否顯示一個相關的代碼或配置文件片段 - 基本上,[mcve]。請參考[問]。 –

回答

0

您需要的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)