按照您说的用登录页面的cookie获取图片,我试了一下,还是不行。
不知为何Get不到登录画面HTML呢
验证码取得没有问题。
Get登录画面的抓包信息。
HTTP/1.0 302 Moved Temporarily
Cache-Control: private
Content-Type: text/html; charset=utf-8
Location: http://login.ebdoor.com/GET_USER ... AVE_USER_TOKEN.ASPX
Server: Microsoft-IIS/7.5
Set-Cookie: ASP.NET_SessionId=1qkxzpwkpaj1w2dq23uvbk4y; domain=ebdoor.com; path=/; HttpOnly
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Sat, 05 Jul 2014 04:04:20 GMT
Content-Length: 292
X-Cache: MISS from CT-TJTG-19-12.fastcdn.com
X-Cache: MISS from CNC-SDJN-209-29.fastcdn.com
Connection: keep-alive
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="http://login.ebdoor.com/GET_USER_TOKEN.aspx?UserVisitUrl=http%3a%2f%2flogin.ebdoor.com%2fMember%2fLogin.aspx&ReturnUrl=http%3a%2f%2flogin.ebdoor.com%2fSAVE_USER_TOKEN.ASPX">here</a>.</h2>
</body></html>
[C#] 纯文本查看 复制代码 string code_cookie;
public MainWindow()
{
InitializeComponent();
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://login.ebdoor.com/Member/Login.aspx",
ResultType = ResultType.Byte,
ProxyIp = "ieproxy"
};
item.Header.Add("DNT", "1");
HttpResult result = http.GetHtml(item);
code_cookie = result.Cookie;
item = new HttpItem()
{
URL = "http://login.ebdoor.com/Resource/ValidateCode/ValidateCode.aspx",
ResultType = ResultType.Byte,
Cookie = code_cookie,
ProxyIp = "ieproxy"
};
result = http.GetHtml(item);
this.image1.Source = byteArrayToImage(result.ResultByte);
}
private BitmapImage byteArrayToImage(byte[] Bytes)
{
BitmapImage result = new BitmapImage();
result.BeginInit();
result.StreamSource = new MemoryStream(Bytes);
result.EndInit();
return result;
}
private void Login_Click(object sender, RoutedEventArgs e)
{
HttpHelper http = new HttpHelper();
string fr_gdcode = textBox1.Text.Trim();
string Ebdoor_PostData = "__EVENTTARGET=LinkButton_Submit&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUKLTQ1NTQyMTQzOGRk&TextBox_LoginAccount=shbounty&TextBox_LoginPassword=123456&Hidden_Valid=c8050f53-11cf-4660-ada3-b69854b7beb3&TextBox_ValidateCode={0}";
HttpItem item = new HttpItem()
{
URL = "http://login.ebdoor.com/member/login.aspx",
Method = "post",
Referer = "http://login.ebdoor.com/member/login.aspx",
Host = "login.ebdoor.com",
Postdata = String.Format(Ebdoor_PostData, fr_gdcode),
ContentType = "application/x-www-form-urlencoded",
Encoding = Encoding.UTF8,
Cookie = code_cookie,
ProxyIp = "ieproxy"
};
item.Header.Add("DNT", "1");
HttpResult result = http.GetHtml(item);
if (result.StatusCode != HttpStatusCode.OK){
MessageBox.Show("登录失败");
}
} |