基本信息
源码名称:读取WebBrowser中的Cookies(含Session)信息 并赋值给HttpWebRequest 执行模拟网页操作
源码大小:0.07M
文件格式:.zip
开发语言:C#
更新时间:2013-01-05
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 16 元×
微信扫码支付:16 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
通常大家通过 webbrowser.document.cookies 只能得到cookie但是得不到 session,这个实例也得到了session
private void btnOpen_Click(object sender, EventArgs e) { this.webBrowser1.Navigate(this.txtUrl.Text); //string url = this.txtUrl.Text; //System.Diagnostics.Process.Start(url); } private void btnSet_Click(object sender, EventArgs e) { var realCookie = getCookie(GetCookieString(this.txtUrl.Text)); var bwCookie = getCookie(this.webBrowser1.Document.Cookie); MessageBox.Show(getCookie(this.webBrowser1.Document.Cookie).Count.ToString() "--" getCookie(GetCookieString(this.txtUrl.Text)).Count.ToString() "\r\n" this.webBrowser1.Document.Cookie "\r\n new:\r\n" GetCookieString(this.txtUrl.Text)); MessageBox.Show(bwCookie.Count.ToString() ":\r\n" bwCookie.GetCookieHeader(new Uri(this.txtUrl.Text)).Replace(";",";\r\n") "\r\n 真实cookies(" realCookie.Count.ToString() "):\r\n" realCookie.GetCookieHeader(new Uri(this.txtUrl.Text)).Replace(";",";\r\n")); }
private void btnTest_Click(object sender, EventArgs e) { //string strHtml = Kt.Framework.Common.NetSocket.GetUrl(this.txtUrl.Text, getCookie(), GetCookieString(this.txtUrl.Text)); //string strHtml = Kt.Framework.Common.NetSocket.GetUrl(this.txtUrl.Text,GetCookieString(this.txtUrl.Text)); string strHtml = NetSocket.GetUrl(this.txtUrl.Text, getCookie(GetCookieString(this.txtUrl.Text))); Process vProcess = Process.Start("notepad.exe"); while (vProcess.MainWindowHandle == IntPtr.Zero) vProcess.Refresh(); IntPtr vHandle = FindWindowEx(vProcess.MainWindowHandle, IntPtr.Zero, "Edit", null); SendMessage(vHandle, WM_SETTEXT, 0, strHtml); }