惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Schneier on Security
N
News and Events Feed by Topic
量子位
S
Secure Thoughts
V2EX - 技术
V2EX - 技术
Hugging Face - Blog
Hugging Face - Blog
S
Security Affairs
J
Java Code Geeks
Schneier on Security
Schneier on Security
Google Online Security Blog
Google Online Security Blog
TaoSecurity Blog
TaoSecurity Blog
小众软件
小众软件
S
SegmentFault 最新的问题
www.infosecurity-magazine.com
www.infosecurity-magazine.com
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Security Archives - TechRepublic
Security Archives - TechRepublic
P
Privacy International News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
博客园 - 聂微东
T
Tor Project blog
博客园 - Franky
C
CERT Recently Published Vulnerability Notes
Cyberwarzone
Cyberwarzone
罗磊的独立博客
博客园_首页
The Cloudflare Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
Forbes - Security
Forbes - Security
V
Vulnerabilities – Threatpost
Security Latest
Security Latest
腾讯CDC
Simon Willison's Weblog
Simon Willison's Weblog
S
Securelist
博客园 - 【当耐特】
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Threat Research - Cisco Blogs
博客园 - 司徒正美
AWS News Blog
AWS News Blog
WordPress大学
WordPress大学
Jina AI
Jina AI
G
GRAHAM CLULEY
V
V2EX
L
LINUX DO - 最新话题
H
Heimdal Security Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
IT之家
IT之家

博客园 - lovingbird

Python中的数字 Python中的字符串常用处理方法 vs2015中SQLSERVER数据库项目引用系统视图 SQL Server 2008通过LinkServer连接MySQL 删除sqlserver代理任务脚本 ldap实现用户认证 mysql下将分隔字符串转换为数组 从ICassFactory为CLSID为{17BCA6E8-A950-497E-B2F9-AF6AA475916F}的COM组件创建实例失败问题解决方法 IIS7下ajax报未定义错误 Access restriction错误解决办法 通过.browser文件设置chrome等浏览器的兼容性 通过web.config设置网站默认页 NC调试时客户端报错:nc.ui.sm.login.Loader2.<init> 本地连接与无线网络连接消失的解决办法 asp.net中使用ajax提示“'Sys'未定义”错误 解决ora-12514 问题 SQLServer常用命令 WIN7的各种安装方法 Access建表语句 - lovingbird - 博客园
将WebBrowser的cookie信息传给HttpWebRequest - lovingbird - 博客园
lovingbird · 2010-05-05 · via 博客园 - lovingbird

先建一个"CookieContainer" 把WebBrowser中的Cookie保存在里面
        
    //在WebBrowser中登录 cookie保存在 WebBrowser.Document.Cookie中
            
             CookieContainer myCookieContainer = new CookieContainer();


             //String 的Cookie 要转成 Cookie型的 并放入CookieContainer中
             string cookieStr = webBrowser1.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.hao123.com";//必须写对
                 myCookieContainer.Add(ck);
             }


             HttpWebRequest hreq = (HttpWebRequest)HttpWebRequest.Create("http://www.hao123.com/search.asp");
             hreq.Method = "POST";
             hreq.ContentType = "application/x-www-form-urlencoded";
           
             //自己创建的CookieContainer
             hreq.CookieContainer = myCookieContainer;
           
             string postdata = "id=2005&action=search&name=";
             byte[] byte1 = Encoding.ASCII.GetBytes(postdata);
             hreq.ContentLength = byte1.Length;
            
             Stream poststream = hreq.GetRequestStream();
             poststream.Write(byte1, 0, byte1.Length);
             poststream.Close();
        
             HttpWebResponse hres = (HttpWebResponse)hreq.GetResponse();