首页 新闻 会员 周边

获取天猫页面Cookie问题

0
[已解决问题] 解决于 2016-02-16 09:56

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值

WYan13的主页 WYan13 | 初学一级 | 园豆:42
提问于:2015-12-29 17:52
< >
分享
最佳答案
0

在header里面找找Set-Cookie

奖励园豆:5
Supper_litt | 小虾三级 |园豆:827 | 2015-12-30 08:54
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册