|
楼主 |
发表于 2013-9-3 15:07:08
|
显示全部楼层
for (int i = 1; i <= 5000; i++)
{//登录
if (!flg)
{
if (i > 30)
{
Thread.Sleep(5000);
}
Thread.Sleep(500);
#region 登录
try
{
ListInfo.Add(dic["Name"].ToString() + "正在登录 " + DateTime.Now.ToString() + " 代理IP【" + dic["ProxyIp"] + "】");
item = new HttpItem()
{
URL = "http://58.18.212.100:8080/cgsdms/preAsign/ExamSiteAction!checkUserInfo.action",//URL 必需项
Method = "Post",//URL 可选项 默认为Get
ContentType = "application/x-www-form-urlencoded",//返回类型
UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;",//listAgent[randomNum.Next(4)],//"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0",//用户的浏览器类型,版本,操作系统
Postdata = "person.sfzmmc=A&person.sfzmhm=" + dic["UID"].ToString() + "&lsh=" + dic["Pwd"].ToString() + "&checkNum=" + dic["Code"].ToString(),
ProxyIp = dic["ProxyIp"],
Cookie = cookie,
Timeout = 10000,
ResultType = ResultType.String,
KeepAlive=false,
ProtocolVersion = HttpVersion.Version10,
};
item.Header.Add("Origin", " http://58.18.212.100:8080");
item.Header.Add("x-requested-with", "XMLHttpRequest");
//得到HTML代码
HttpResult result = new HttpResult();
result = http2.GetHtml(item);
List<string> list = BackDistillDNs(result.Html, "#info'\\).html\\('(.*?)'\\);");
if (result.Html.Contains("基础连接已经关闭") || result.Html.Contains("操作超时") || result.Html.Contains("远程服务器返回错误") || result.Html.Contains("无法连接到远程服务器") || result.Html.Contains("未经授权"))
{
ListInfo.Add(dic["Name"].ToString() + result.Html + ",程序将自动重试" + i.ToString() + "次 " + DateTime.Now.ToString() + " 代理IP【" + dic["ProxyIp"] + "】");
if (i == 5 || i == 10 || i == 20 || i == 30 || i == 60 || i == 80 || i == 100 || i == 150)
{
dic["ProxyIp"] = GetIP();
}
Thread.Sleep(3000);
flg = false;
}
if (result.Html.Contains("body onload=\"pdpxshrq();\""))
{
ListInfo.Add(dic["Name"].ToString() + "登录成功 " + DateTime.Now.ToString() + " 代理IP【" + dic["ProxyIp"] + "】");
return true;
}
}
catch (Exception ex)
{
ListInfo.Add(dic["Name"].ToString() + ex.Message + " " + DateTime.Now.ToString() + " 代理IP【" + dic["ProxyIp"] + "】");
return false;
}
#endregion
}
}
|
|