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

推荐订阅源

S
SegmentFault 最新的问题
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Cisco Talos Blog
Cisco Talos Blog
Spread Privacy
Spread Privacy
Scott Helme
Scott Helme
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Securelist
酷 壳 – CoolShell
酷 壳 – CoolShell
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
I
Intezer
博客园 - 叶小钗
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
雷峰网
雷峰网
量子位
Security Latest
Security Latest
P
Proofpoint News Feed
P
Privacy International News Feed
P
Palo Alto Networks Blog
D
DataBreaches.Net
大猫的无限游戏
大猫的无限游戏
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Google Online Security Blog
Google Online Security Blog
Webroot Blog
Webroot Blog
云风的 BLOG
云风的 BLOG
N
Netflix TechBlog - Medium
Vercel News
Vercel News
博客园 - 【当耐特】
C
CERT Recently Published Vulnerability Notes
Hugging Face - Blog
Hugging Face - Blog
月光博客
月光博客
Hacker News - Newest:
Hacker News - Newest: "LLM"
K
Kaspersky official blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Stack Overflow Blog
Stack Overflow Blog
AWS News Blog
AWS News Blog
博客园 - Franky
爱范儿
爱范儿
T
Tor Project blog
The GitHub Blog
The GitHub Blog
宝玉的分享
宝玉的分享
小众软件
小众软件
L
LINUX DO - 最新话题
Application and Cybersecurity Blog
Application and Cybersecurity Blog
W
WeLiveSecurity
SecWiki News
SecWiki News
L
LangChain Blog
I
InfoQ

博客园 - Ж╰ァ流星

打字复印店发展方向 公司绝不会告诉你的20大秘密 值得一看很受用 EXT 学习视频 2009搜索引擎排名 进度条 图标大搜索 简繁转换工具 QQ技术相关资料 IT人 不要一辈子靠技术生存(转) 花也能长成这样?“色” 大附件上传控件 Telerik.QuickStart RadUpload.Net2 明星个人博客地址 如何让网站被百度和google快速收录 Sql2005安装图解 AjaxPro使用说明 FileUpload 控件 禁止手动输入 javascript 学习 java 开放教材 2009年你想过要赚到10万吗?
程序读取需要登录网页的C#代码 - Ж╰ァ流星 - 博客园
Ж╰ァ流星 · 2009-08-14 · via 博客园 - Ж╰ァ流星

转:http://www.cnblogs.com/uslang/articles/1227163.html
public static string PostData(string url,string indata,CookieContainer myCookieContainer)
 2        {
 3            string outdata=""
 4            HttpWebRequest myHttpWebRequest=(HttpWebRequest)WebRequest.Create(url); 
 5            myHttpWebRequest.ContentType="application/x-www-form-urlencoded"
 6            myHttpWebRequest.ContentLength=indata.Length; 
 7            myHttpWebRequest.Method="POST"
 8            myHttpWebRequest.CookieContainer=myCookieContainer; 
 9            Stream myRequestStream=myHttpWebRequest.GetRequestStream(); 
10            StreamWriter myStreamWriter=new StreamWriter(myRequestStream,Encoding.GetEncoding("gb2312"));                 
11            myStreamWriter.Write(indata); 
12            myStreamWriter.Close(); 
13            myRequestStream.Close(); 
14            HttpWebResponse myHttpWebResponse=(HttpWebResponse)myHttpWebRequest.GetResponse(); 
15            myHttpWebResponse.Cookies=myCookieContainer.GetCookies(myHttpWebRequest.RequestUri); 
16            Stream myResponseStream=myHttpWebResponse.GetResponseStream(); 
17            StreamReader myStreamReader=new StreamReader(myResponseStream,Encoding.GetEncoding("gb2312")); 
18            outdata=myStreamReader.ReadToEnd(); 
19            myStreamReader.Close(); 
20            myResponseStream.Close();
21            return outdata;
22        }

CookieContainer myCookieContainer=new CookieContainer(); 
string url="?????????????????";//登录页面的链接,看from里面的action
string loginfo="?????????????????";//登录字符串,例如user=??&pass=????
PostData(url,loginfo,myCookieContainer);//这个返回的应该是登录成功的信息,而且写好cookie了

url
="???????????";//这个就是想要读取的页面地址,普通情况用StreamReader是读不到的喔
PostData(url,"",myCookieContainer);//返回的就是目标页面,完成,如果还要连续读其它页面,继续这两句代码就行了(cookie已经保存了,自己用就好了).