Answer the question
In order to leave comments, you need to log in
Why does the IDE write that the header of the request to the site is incorrect?
Hello everyone! I want to get the content of one site, it turned out that to get the page markup, you need to specify this in the request headers:
Accept: text/html,application/xhtml+xml,application/xml;
Accept-Encoding: gzip, deflate, br
As a result, the code has the following section:
System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)WebRequest.Create(url);
req.UserAgent = "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36";
//var reqProxy = ProxyBalancer.GetHttpRequest(out proxyAddress, out proxyIP, out proxyType, url, new int[] { 1 });
req.Proxy = new WebProxy(reqProxy, true);
req.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br");
req.Headers.Add(HttpRequestHeader.Accept, "text/html, application/xhtml+xml, application/xml");
//AddLogMessage("Proxy: " + proxyAddress, LogMessageType.Info); */
req.AutomaticDecompression = DecompressionMethods.GZip;
req.CookieContainer = cookies;
System.Net.HttpWebResponse resp = (System.Net.HttpWebResponse)req.GetResponse();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question