我想使用HttpClientHandler設置anglesharp.io的超時值。使用HttpClientHandler設置超時
這個問題表明,它是可能的:https://github.com/AngleSharp/AngleSharp/issues/266
我得到頁是這樣的:
NetworkCredential proxyCreds = new NetworkCredential(proxy.User, proxy.Pass);
WebProxy wProxy = new WebProxy(proxy.Ip + ":" + proxy.Port, false)
{
UseDefaultCredentials = false,
Credentials = proxyCreds,
};
HttpClientHandler httpClientHandler = new HttpClientHandler()
{
Proxy = wProxy,
PreAuthenticate = true,
UseDefaultCredentials = false
};
var config = Configuration.Default.WithRequesters(httpClientHandler);
var document = await BrowsingContext.New(config).OpenAsync(address);
我不能看到可用來設置超時的任何屬性。我如何設置超時時間?
您無法在'HttpClientHandler'上設置超時。您需要將'HttpClientHandler'傳遞給'HttpClient'。檢查此 - https://blogs.msdn.microsoft.com/henrikn/2012/08/07/httpclient-httpclienthandler-and-webrequesthandler-explained/ –
Anglesharp正在抽象此過程。我鏈接的頁面說我需要製作IRequester,但我不確定那是什麼。我已經直接使用httpclient做了解決方法,但很好奇如何使它在angleharp中工作。 – Guerrilla
那麼在這種情況下,你可能必須通過角度衝突的API /文檔 –