|
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://59.203.5.92/jguaac-server/login?p=&loginType=normal&service=http%3A%2F%2F59.203.7.31%2Fjgtybl%2F",//URL 必需项
Method = "GET",//URL 可选项 默认为Get
Timeout = 10000,//连接超时时间 可选项默认为100000
ReadWriteTimeout = 30000,//写入Post数据超时时间 可选项默认为30000
IsToLower = false,//得到的HTML代码是否转成小写 可选项默认转小写
Cookie = "",//字符串Cookie 可选项
UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0",//用户的浏览器类型,版本,操作系统 可选项有默认值
Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",// 可选项有默认值
//ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
Referer = "http://59.203.5.92/jguaac-server/logout?service=http%3A%2F%2F59.203.7.31%2Fjgtybl%2F",//来源URL 可选项
//Allowautoredirect = False,//是否根据301跳转 可选项
//AutoRedirectCookie = False,//是否自动处理Cookie 可选项
//CerPath = "d:\123.cer",//证书绝对路径 可选项不需要证书时可以不写这个参数
//Connectionlimit = 1024,//最大连接数 可选项 默认为1024
//Postdata = "userid=" + userid + "&pwd=" + pwd + "&lang=cn&cmd=CLIENT_USER_LOGIN&sid=&deviceType=pc&_CACHE_LOGIN_TIME_=" + GetTimeStamp() + "&pwdEncode=RSA&timeZone=8",//Post数据 可选项GET时不需要写
//ProxyIp = "192.168.1.105:2020",//代理服务器ID 可选项 不需要代理 时可以不设置这三个参数
//ProxyPwd = "123456",//代理服务器密码 可选项
//ProxyUserName = "administrator",//代理服务器账户名 可选项
ResultType = ResultType.String,//返回数据类型,是Byte还是String
};
try
{
HttpResult result = http.GetHtml(item);
if (result.StatusCode != HttpStatusCode.OK)
{
ErrInfo("网站不能正常访问,请检查网络是否畅通,或稍后再试!");
return;
}
string html = result.Html;
cookie = result.Cookie;
//解析网页数据
log("cookie:" + cookie); //这里可以获取cookie
loginUrl = nd.GetAttributeValue("action", "");
////加载验证码
item.URL = "http://59.203.5.92/jguaac-server/imageServlet?now=" + GetTimeStamp();
item.Cookie = cookie;
item.Accept = "image/webp,image/apng,image/*,*/*;q=0.8";
item.ResultType = ResultType.Byte;
result = http.GetHtml(item);
picBox.Image = byteArrayToImage(result.ResultByte);
log("验证码cookie:" + result.Cookie);//这里变成空了
|
|