[C#] 纯文本查看 复制代码 public Image checkVerify(string qq, out string outCookies)
{
Image codeImage = null;
string url = "http://check.ptlogin2.qq.com/check?uin=" + qq + "&appid=1003903&r=0.5058025715431";
#region httphelper
HttpHelper httphelper = new HttpHelper();
HttpItem httpitem = new HttpItem()
{
Referer = "http://d.web2.qq.com/proxy.html?v=20110331002&callback=1&id=2",
UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E)",
Accept = "*/*",
ContentType = "application/x-www-form-urlencoded; charset=UTF-8",
Encoding = Encoding.UTF8,
URL = url
};
HttpResult httpresult = httphelper.GetHtml(httpitem);
string result = httpresult.Html;
outCookies = httpresult.Cookie;
//CookieContainer cookiecontainer = new CookieContainer();
//_HttpHelper.GetHtml(url, cookiecontainer);
#endregion
//string result = getHtml(url, "get", null);
hex16 = Utils.gethex(result);
if (result.IndexOf("!") < 0)
{
//需要验证图片
String verifyUrl = "http://captcha.qq.com/getimage?aid=1003903&uin=" + qq + "&r=" + rd.NextDouble();
#region 图片
httpitem = new HttpItem()
{
Referer = "http://d.web2.qq.com/proxy.html?v=20110331002&callback=1&id=2",
UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E)",
Accept = "*/*",
ContentType = "application/x-www-form-urlencoded; charset=UTF-8",
Encoding = Encoding.UTF8,
Cookie = outCookies,
URL = verifyUrl,
ResultType = ResultType.Byte
};
httpresult = httphelper.GetHtml(httpitem);
Image img = byteArrayToImage(httpresult.ResultByte);
#endregion
codeImage = img;//Image.FromStream(img);
outCookies = httpresult.Cookie;
//pubModel.cookie = httpresult.Cookie;
}
else
{
this.verifyCode = result.Substring(result.IndexOf("!"), 4);
this.hex16 = result.Substring(result.IndexOf("\\"), 32);
this.hex16 = this.hex16.Replace("\\x", "");
}
pubModel.cookie = outCookies;
ManageAccountAdd(qq, pubModel);
//cookie = httpresult.Cookie;
return codeImage;
} |