网页数据抓取怎么写(本地数据抓取问题(2015年03月23日))
优采云 发布时间: 2022-03-08 18:02网页数据抓取怎么写(本地数据抓取问题(2015年03月23日))
数据抓取问题,本地正常,上传到服务器超时
使用 MSXML2.XMLHTTP 组件制作的数据爬取小程序
C# 代码
MSXML2.XMLHTTP xmlhttp = new MSXML2.XMLHTTPClass();
for (int i = 0; i < url.Count; i++)
{
xmlhttp.open("POST", url[i].Site+webaddre, true, null, null);
//xmlhttp.setRequestHeader("Content-Type", "text/xml;charset=gb2312");
xmlhttp.send(null);
Num num = null;
if (xmlhttp.readyState == 4)
{
string str = string.Empty;
if (url[i].Name == "百度")
str = Encoding.Default.GetString((byte[])xmlhttp.responseBody);
else
str = xmlhttp.responseText;
MatchCollection maction = Regex.Matches(str, url[i].Patter);
if(maction[0].Value != null)
num = new Num(url[i].Name,maction[0].Value,"0");
else
num = new Num(url[i].Name, "没抓到", "0");
cont.Add(num);
}
else
{
num = new Num(url[i].Name, "抓取超时","0");
cont.Add(num);
//return;
}
本地正常,可以抓到你要的数据,上传到服务器后可以全部超时
- - - 解决方案 - - - - - - - - - -
给我一些分数。我想问问题,但没有积分。他们给大师们很多分数。照顾新人。。
- - - 解决方案 - - - - - - - - - -
先找原因,程序异常?网络不好?或者是其他东西。. .
- - - 解决方案 - - - - - - - - - -
会不会是服务器设置有问题,你先测试一下你的xmlhttp对象是否创建成功?
- - - 解决方案 - - - - - - - - - -
这与您本地机器的安全级别有关吗?