|
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://passport.cnblogs.com/login.aspx",//URL 必需项
Encoding = System.Text.Encoding.GetEncoding("utf-8"),//URL 可选项 默认为Get
Method = "post",//URL 可选项 默认为Get
IsToLower = false,//得到的HTML代码是否转成小写 可选项默认转小写
Cookie = "",//字符串Cookie 可选项
Referer = "",//来源URL 可选项
Postdata = "tbUserName=3972505&tbPassword=3972505",//Post数据 可选项GET时不需要写
Timeout = 100000,//连接超时时间 可选项默认为100000
ReadWriteTimeout = 30000,//写入Post数据超时时间 可选项默认为30000
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",//用户的浏览器类型,版本,操作系统 可选项有默认值
ContentType = "text/html",//返回类型 可选项有默认值
Allowautoredirect = true,//是否根据301跳转 可选项
};
HttpResult result = http.GetHtml(item);
string scookie = HttpCookieHelper.CookieFormat("ID", HttpCookieHelper.GetCookieValue("ID", result.Cookie));
scookie += HttpCookieHelper.CookieFormat("T", HttpCookieHelper.GetCookieValue("T", result.Cookie));
scookie += HttpCookieHelper.CookieFormat("DottextCookie", HttpCookieHelper.GetCookieValue("DottextCookie", result.Cookie));
http = new HttpHelper();
item = new HttpItem()
{
URL = "http://home.cnblogs.com/",//URL这里都是测试URl 必需项
Encoding = Encoding.UTF8,
Method = "get",//URL 可选项 默认为Get
Cookie = scookie
};
result = http.GetHtml(item);
richTextBox1.Text = result.Html;
|
|