string sRefer = "https://list.tmall.com/search_product.htm?q=TALK+BAND+B2+%D6%C7%C4%DC%CA%D6%BB%B7+%C0%B6%D1%C0%B6%FA%BB%FA+B2+%CD%A8%BB%B0%CA%D6%BB%B7&sort=s&style=g&from=sn_1_brand&cat=50024436&brand=11813&search_condition=7#J_crumbs";
//System.GC.Collect();
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
HttpWebRequest hr = (HttpWebRequest)WebRequest.Create(URL);
hr.UserAgent = "Mozilla/5.0 (Windows NT 5.2; rv:42.0) Gecko/20100101 Firefox/42.0";
hr.Headers.Add("Accept-Encoding", "gzip, deflate");
hr.Method = "GET";
hr.ContentType = "text/html;charset=GBK";
hr.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
hr.Referer = sRefer;
hr.KeepAlive = true;
hr.ReadWriteTimeout = 10000;
hr.Timeout = 15000;
hr.CookieContainer = new CookieContainer();
HttpWebResponse wsp = (HttpWebResponse)hr.GetResponse();
这个时候wsp.Cookies.Count为0。
怎么解决下呢?实现成功获取页面Cookie值
在header里面找找Set-Cookie