gpt4 book ai didi

c# - HttpWebResponse 超时

转载 作者:太空宇宙 更新时间:2023-11-03 23:03:00 25 4
gpt4 key购买 nike

我在下面的代码中收到超时异常。只有这个网站有问题。有什么问题?

string ackoURL = "https://www.zomato.com/sk/brno/u-heligonky-z%C3%A1brdovice-brno-st%C5%99ed/denn%C3%A9-menu";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ackoURL);
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
//this code is never executed
}

我尝试修改 SecurityProtocol、KeepAlive 和类似的东西。没有成功。

最佳答案

它正在等待这些 header

enter image description here

..它起作用了

Uri u = new Uri("https://www.zomato.com/sk/brno/u-heligonky-z%C3%A1brdovice-brno-st%C5%99ed/denn%C3%A9-menu");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(u);
request.AutomaticDecompression = DecompressionMethods.GZip;
request.Headers.Add("Accept-Language", "en-gb,en;q=0.5");
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using(Stream stream = response.GetResponseStream())
{
using(StreamReader reader= new StreamReader(stream))
{
var result = reader.ReadToEnd();

}
}
}

关于c# - HttpWebResponse 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42400295/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com