zoukankan
html css js c++ java
C# 模拟用户登录
///
<summary>
///
登录网站并获取Cookies
///
</summary>
///
<returns>
成功登录的Cookie信息
</returns>
public
static
CookieContainer Get_Login()
{
CookieContainer cc
=
new
CookieContainer();
string
FormURL
=
http://www.fy681.com/login.aspx
;
//
处理表单的绝对URL地址
string
FormData
=
"
username=dahai163&passwd=123
"
;
//
表单需要提交的参数,注意改为你已注册的信息。
ASCIIEncoding encoding
=
new
ASCIIEncoding();
byte
[] data
=
encoding.GetBytes(FormData);
HttpWebRequest request
=
(HttpWebRequest)WebRequest.Create(FormURL);
request.Method
=
"
POST
"
;
//
数据提交方式
request.ContentType
=
"
application/x-www-form-urlencoded
"
;
request.ContentLength
=
data.Length;
request.UserAgent
=
"
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
"
;
//
模拟一个UserAgent
Stream newStream
=
request.GetRequestStream();
newStream.Write(data,
0
, data.Length);
newStream.Close();
request.CookieContainer
=
cc;
HttpWebResponse response
=
(HttpWebResponse)request.GetResponse();
cc.Add(response.Cookies);
Stream stream
=
response.GetResponseStream();
string
WebContent
=
new
StreamReader(stream, System.Text.Encoding.Default).ReadToEnd();
return
cc;
}
查看全文
相关阅读:
Codeforces Round #417 C. Sagheer and Nubian Market
linux 终端抓包命令
计算机网络体系结构分析
排序算法-快速排序
排序算法-堆排序
排序算法-希尔排序
排序算法-插入排序
排序算法-冒泡排序
排序算法-选择排序
杂谈:终端小工具
原文地址:https://www.cnblogs.com/wanyuan8/p/3559144.html
最新文章
机器学习——几种距离度量方法比较
解决Git 克隆代码 The remote end hung up unexpectedly错误
Java集合 -- HashSet 和 HashMap
Java 接口和多态
Java 继承
Java 简化版学生管理系统(IO版)
Java IO流及应用(一)
Java集合 -- ArrayList集合及应用
Java 之常用API(一)
搭建hustoj
热门文章
Centos6.5 下搭建LAMP环境
Centos7 下安装Apache2 + MySQL + PHP7
hustoj搭建--常见问题
Linux 下MySQL的基本操作
Linux(Ubuntu16.04)下添加新用户
Linux 中各个文件夹的作用
用Java开发贪吃蛇游戏
Linux下vim(文本编译器)的使用
Linux 中常用命令
Codeforces Round #419 A+B
Copyright © 2011-2022 走看看