private void alimmlogin()
{
// GET http://pub.alimama.com/promo/search/index.htm?toPage=1&queryType=2 HTTP/1.1
//Host: pub.alimama.com
//Connection: keep-alive
//Cache-Control: max-age=0
//Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
//Upgrade-Insecure-Requests: 1
//User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36
//Referer: http://pub.alimama.com/?spm=a2320.7388781.a214tr8.13.UBCxvg
XJHTTP xjhttp = new XJHTTP();
string cookie = xjhttp.GetCookieByWininet("http://pub.alimama.com"); //获取淘宝的Cookie
CookieContainer cc = xjhttp.StringToCookie("http://pub.alimama.com", cookie); //将字符串cookie转换为CookieContainer 对象
HttpHelpers http = new HttpHelpers();
HttpItems hi = new HttpItems();
hi.URL = "http://pub.alimama.com/promo/search/index.htm?toPage=1&queryType=2";//访问我的淘宝
hi.Referer = " http://pub.alimama.com/?spm=a2320.7388781.a214tr8.13.UBCxvg";
hi.UserAgent = " Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94";
hi.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
hi.Method = "get";
hi.Container = cc; //设置获取到的Cookie
HttpResults hr = http.GetHtml(hi); //得到请求结果
string html = hr.Html;
richTextBox1.Text = html;
}
我写的这段代码 运行起来报错“确保cookie不会超过cookie容器所允许的最大值“ |