小编bin*_* li的帖子

C#HTTPWebRequest不能用于定期访问URL吗?

我正在编写一个程序来使用C#HTTTWebRequest来抓取网页.由于我需要监视特定URL的更新,因此我按如下方式编写代码.但是,我注意到我只能得到两次回复.在那之后,它没有得到回应.即使我将时间延长到一分钟,我仍然遇到同样的问题.我不明白为什么.你能帮我个忙吗?非常感谢!

GreatFree

while (true)
{
    WebRequest http = HttpWebRequest.Create("http://www.sina.com.cn");
    HttpWebResponse response = (HttpWebResponse)http.GetResponse();
    Console.WriteLine(response.LastModified);
    Thread.Sleep(5000);
}
Run Code Online (Sandbox Code Playgroud)

c# http

2
推荐指数
2
解决办法
952
查看次数

标签 统计

c# ×1

http ×1