贴代码:
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(strURL);
myHttpWebRequest.ContentType = "text/html";
myHttpWebRequest.Method = "GET";
myHttpWebRequest.Referer = strReferer;
myHttpWebRequest.Headers.Add("cookie:" + cookieHeader);
myHttpWebRequest.Timeout = 1000000;
HttpWebResponse response = null;
System.IO.StreamReader sr = null;
response = (HttpWebResponse)myHttpWebRequest.GetResponse();
sr = new System.IO.StreamReader(response.GetResponseStream(), Encoding.GetEncoding(charset));
string strResult = string.Empty,temp=string.Empty;
//方式一
while(string.IsNullOrEmpty(temp=sr.ReadLine()))
{
strResult += temp;
}
//方式二
//string strResult = sr.ReadToEnd();
return strResult;
我请求的地址中间有跳转,我post数据给它后,他会跳转两次。我要拿最后的源代码。
总是报错,各位大大指教阿。
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(strURL);
myHttpWebRequest.ContentType = "text/html";
myHttpWebRequest.Method = "GET";
myHttpWebRequest.Referer = strReferer;
myHttpWebRequest.Headers.Add("cookie:" + cookieHeader);
myHttpWebRequest.Timeout = 1000000;
HttpWebResponse response = null;
System.IO.StreamReader sr = null;
response = (HttpWebResponse)myHttpWebRequest.GetResponse();
sr = new System.IO.StreamReader(response.GetResponseStream(), Encoding.GetEncoding(charset));
string strResult = string.Empty,temp=string.Empty;
//方式一
while(string.IsNullOrEmpty(temp=sr.ReadLine()))
{
strResult += temp;
}
//方式二
//string strResult = sr.ReadToEnd();
return strResult;
我请求的地址中间有跳转,我post数据给它后,他会跳转两次。我要拿最后的源代码。
总是报错,各位大大指教阿。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货