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

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Troy Hunt's Blog
P
Proofpoint News Feed
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
K
Kaspersky official blog
Cyberwarzone
Cyberwarzone
T
Tor Project blog
Cisco Talos Blog
Cisco Talos Blog
S
Securelist
L
Lohrmann on Cybersecurity
Security Latest
Security Latest
T
Threatpost
H
Heimdal Security Blog
W
WeLiveSecurity
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
GRAHAM CLULEY
IT之家
IT之家
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
TaoSecurity Blog
TaoSecurity Blog
A
About on SuperTechFans
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
Last Week in AI
Last Week in AI
T
The Blog of Author Tim Ferriss
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Microsoft Azure Blog
Microsoft Azure Blog
Hugging Face - Blog
Hugging Face - Blog
Google DeepMind News
Google DeepMind News
量子位
Stack Overflow Blog
Stack Overflow Blog
Know Your Adversary
Know Your Adversary
B
Blog RSS Feed
阮一峰的网络日志
阮一峰的网络日志
WordPress大学
WordPress大学
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
AI
AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
GbyAI
GbyAI
Vercel News
Vercel News
C
Cyber Attacks, Cyber Crime and Cyber Security
Latest news
Latest news
D
Darknet – Hacking Tools, Hacker News & Cyber Security
大猫的无限游戏
大猫的无限游戏
Forbes - Security
Forbes - Security

博客园 - 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();