使用的cookie就是验证码页面的cookie,
用户名和密码正确 没错误
@站长苏飞 求助
[C#] 纯文本查看 复制代码 public Form1()
{
InitializeComponent();
}
string cookie = string.Empty;
private void textBox1_Leave(object sender, EventArgs e)
{
string accountnumber = this.textBox1.Text.Trim();
string url = "http://captcha.qq.com/getimage?uin=" + accountnumber + "&aid=19000501&cap_cd=jhfJXXsrfKysnSz9PyHLhqsbPwFOvckG&0.11803843325515984";
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = url,//URL 必需项
Method = "get",//URL 可选项 默认为Get
IsToLower = false,//得到的HTML代码是否转成小写 可选项默认转小写
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",//用户的浏览器类型,版本,操作系统 可选项有默认值
ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
ResultType = ResultType.Byte
};
HttpResult result = http.GetHtml(item);
cookie = result.Cookie;
//cook = new Cookie("12306login", result.Cookie);
Image code = byteArrayToImage(result.ResultByte);
this.pictureBox1.Image = code;
}
private Image byteArrayToImage(byte[] Bytes)
{
MemoryStream ms = new MemoryStream(Bytes);
Image outputImg = Image.FromStream(ms);
return outputImg;
}
private void button1_Click(object sender, EventArgs e)
{
string verifycode = this.textBox3.Text.Trim();
string username = this.textBox1.Text.Trim();
string password = this.textBox2.Text.Trim();
string url = "http://ptlogin2.qq.com/login?u=" + username + "&p=" + password + "&verifycode=" + verifycode + "&aid=19000501&u1=http%3A%2F%2Fbd.qq.com%2Fnew%2Findex.jsp&h=1&ptredirect=1&ptlang=2052&from_ui=1&dumy=&low_login_enable=0®master=&fp=loginerroralert&action=1-12-1404779717678&mibao_css=&t=1&g=1&js_ver=10084&js_type=1&login_sig=LnpY8AWplbJsxL*ZWRMCQjZdfrBXRANrh0yKiyaTTrIyFGPClAerq4OnxSYj3WXJ&pt_uistyle=17&pt_rsa=0 HTTP/1.1";
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = url,//URL 必需项
Method = "get",//URL 可选项 默认为Get
IsToLower = false,//得到的HTML代码是否转成小写 可选项默认转小写
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",//用户的浏览器类型,版本,操作系统 可选项有默认值
ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
ResultType = ResultType.Byte,
Cookie=cookie
};
HttpResult result = http.GetHtml(item);
cookie = result.Cookie;
this.richTextBox1.Text = result.Html;
}
|