WebClient.DownloadString result is not match with Browser result 2

后端 未结 3 1280
孤街浪徒
孤街浪徒 2021-01-27 03:33

The following code:

WebClient wc = new WebClient();
wc.Encoding = Encoding.UTF8;
string Url = "http://www.tsetmc.com/t         


        
3条回答
  •  说谎
    说谎 (楼主)
    2021-01-27 04:12

    In Linqpad you can run the below code, variation from Webclient. As you can see from the picture, its due to the Gzip compression which browser automatically handles.

    async void Main()
    {
        using (var handler = new HttpClientHandler())
        {
            handler.AutomaticDecompression = DecompressionMethods.GZip;
            using (HttpClient client = new HttpClient(handler))
            {
                var result = await client.GetStringAsync("http://www.tsetmc.com/tsev2/data/instinfodata.aspx?i=59266699437480384&c=64");
                result.Dump();
            }
        }
    }
    

提交回复
热议问题