得到html代码为什么都一样呢
WebAddr="www.baidu.com"
string MianWeb = "http://google.im286.cn/google.php?domain=" + WebAddr;
WebClient myWebClient = new WebClient();
byte[] myDataBuffer = myWebClient.DownloadData(MianWeb);
string stra = Encoding.Default.GetString(myDataBuffer);
我这样写可得到的结果都是0
用浏览器直接访问http://google.im286.cn/google.php?domain=www.baidu.com 却能得到正确的收录情况 这是为什么呢
[解决办法]
myWebClient.DownloadString看看。
[解决办法]
用httpwatch等软件抓包调试下,看看你的调用和浏览器的有什么不同。
[解决办法]
尝试设置下UserAgent属性,有的网站为了防止机器人会检查UA。
[解决办法]
设置header相关信息
[解决办法]
myWebClient.Headers.Add("Accept", "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*");myWebClient.Headers.Add("Accept-Language", "zh-CN");myWebClient.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1)");myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
[解决办法]
试试其他网址
上述网站我本地浏览器也无法打开