C#基于WebBrowser获取cookie的实现方法
程序员文章站
2022-09-04 23:43:17
本文实例讲述了c#基于webbrowser获取cookie的实现方法。分享给大家供大家参考,具体如下:
private void btnopenurl_click...
本文实例讲述了c#基于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); } } }
希望本文所述对大家c#程序设计有所帮助。