webBrowser获取cookie
Posted HOT SUMMER
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了webBrowser获取cookie相关的知识,希望对你有一定的参考价值。
private void BtnOpenUrl_Click(object sender, EventArgs e) { if (txtUrl.Text != "") { MywebBrowser.Url = new Uri(txtUrl.Text); } } private void BtnGetCookie_Click(object sender, EventArgs e) { CookieContainer myCookieContainer = new CookieContainer(); if (MywebBrowser.Document.Cookie != null) { string cookieStr = MywebBrowser.Document.Cookie; string[] cookstr = cookieStr.Split(‘;‘); foreach (string str in cookstr) { string[] cookieNameValue = str.Split(‘=‘); Cookie ck = new Cookie(cookieNameValue[0].Trim().ToString(), cookieNameValue[1].Trim().ToString()); ck.Domain = "www.google.com"; myCookieContainer.Add(ck); } } }
以上是关于webBrowser获取cookie的主要内容,如果未能解决你的问题,请参考以下文章