用DOM实现文章采集--采集到网页源码(13)
来源:未知 责任编辑:责任编辑 发表时间:2014-04-20 03:40 点击:次
}
#region 检查链接
/// <summary>
/// 检查链接是否存在
/// </summary>
/// <param name="sURL"></param>
/// <param name="AllowBadNum"></param>
public bool UrlExist(string strURL)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strURL);
request.Method = "HEAD";
request.AllowAutoRedirect = false;
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 3.5.21022; .NET CLR 1.0.3705; .NET CLR 1.1.4322)";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode != HttpStatusCode.OK)
{
response.Close();
return false;
}
else
{
return true;
}
}
/// <summary>
/// 检查死链接是否在能容忍的数量内
/// </summary>
/// <param name="URLs"></param>
/// <param name="AllowBadNum"></param>
/// <returns></returns>
public bool UrlExist(List<string> URLs, int AllowBadNum)
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>