110,533
社区成员
发帖
与我相关
我的任务
分享
MyHttp mh = new MyHttp();
mh.sUrl = "http://www.fj987.com/loginin.php";//
mh.fSetMethodPost();
mh.sHwrq.KeepAlive = true;
CookieCollection myCookies = null;
CookieContainer myCookieContainer = new CookieContainer();
mh.sHwrq.CookieContainer = myCookieContainer;
string data = "entype=1&username=zlcp520&password=432503";
mh.fWriteData(data);
mh.fSendAndGet();
string cookieHeader = mh.sHwrq.CookieContainer.GetCookieHeader(new Uri(mh.sUrl));
mh.sHwrp.Close();
//得到cookieHeader为ASPSESSIONIDSQAQDSBA=MGGODBHAEDDHOPGAFDLKCKDL
//每次登录得到的cookieHeader都不同.
//然后获取需要登录才能查看的页面
MyHttp mh = new MyHttp();
mh.sUrl = "http://www.fj987.com/main.html";//
mh.sHwrq.KeepAlive = true;
mh.sHwrq.Headers.Set("Cache-Control", "no-cache");
mh.sHwrq.ContentType = "application/x-www-form-urlencoded";
mh.sHwrq.Headers.Add("cookie:ASPSESSIONIDSQAQDSBA=MGGODBHAEDDHOPGAFDLKCKDL");
mh.sHwrq.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 685; TencentTraveler 4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)";
mh.sHwrq.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/vnd.ms-excel, application/msword, */*";
mh.sHwrq.Headers.Set("Accept-Language", "zh-cn");
mh.sHwrq.Headers.Set("Accept-Encoding", "gzip, deflate");
mh.sHwrq.AllowAutoRedirect = true;
string s = mh.fGetSource(Encoding.GetEncoding("gb2312"));
//获得s却显示你未登录