C#模拟登陆
来源:互联网 发布:显为人知的外国作家 编辑:程序博客网 时间:2024/05/21 09:04
模拟登陆,目的是方便抓取需要登陆后浏览的论坛帖子。
代码摘录如下(注意黑体部分):
//Request #1 (the login)
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
objRequest.Method = "POST";
objRequest.ContentLength = strPost.Length;
objRequest.ContentType = "application/x-www-form-urlencoded";
objRequest.CookieContainer = new CookieContainer();
try
{
myWriter = new StreamWriter(objRequest.GetRequestStream());
myWriter.Write(strPost);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
myWriter.Close();
}
HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
//retain the cookies
foreach (Cookie cook in objResponse.Cookies)
{
myContainer.Add(cook);
}
//Check out the html.
using (StreamReader sr =
new StreamReader(objResponse.GetResponseStream()) )
{
String test = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
- C#模拟登陆
- C# 模拟网站登陆
- C#模拟登陆开心网
- 模拟登陆教务处网站C#
- C#模拟登陆核心代码
- c# 模拟登陆(带验证码)
- C# WinForm Webbrowser 模拟登陆 打卡
- 使用C#的HttpWebRequest模拟登陆网站
- C# 模拟登陆、识别验证码
- 使用C#的HttpWebRequest模拟登陆网站
- 使用C#的HttpWebRequest模拟登陆网站
- 模拟登陆
- 模拟登陆
- 模拟登陆
- 模拟登陆
- 模拟登陆
- 模拟登陆
- c# 使用 HttpWebRequest模拟登陆(附带验证码)
- C# split 使用方法
- 导向恶意网站的搜索引擎搜索结果
- Three.js API文档
- 来自音乐/视频/软件下载站的威胁
- 如何将MyEclipse开发的项目导入到Eclipse中运行
- C#模拟登陆
- PHP---include、include_once、require、require_once
- SQL SERVER 安装出现 “性能计数器注册表配置单元一致性”检查失败 的问题
- 一道Amazon经典的题目,经常会考到,给一个target数字以及一个数组,求所有的加起来为这个数字的组合
- 出差
- ORACLE常用SQL
- Java 理论与实践: 正确使用 Volatile 变量
- linux--sort-split-sed-diff-cmp
- overload和override的区别