|
网址:http://www.pinnacle.com
之前我用Delphi的idhttp去尝试过,一直没破解,后来就用webbrowser去模拟填表了,后来webbrowser一直有内存的问题,所以才放弃用webbrowser,这次打算用httpwebrequest,和用idhttp一样都是登入不成功。。。跪求高手破解,找到原因!
图1:网页post内容
网页post内容
图2:httphelper的post内容
我post之后,去get "https://www1.pinnaclesports.com/members/canvas.asp" 就会重新跳到首页http://www.pinnacle.com
不知道是否需要附带cookies信息,我的代码如下:
private THttpHelper httpWeijing; //THttpHelper 即HttpHelper,习惯将类前面加T类似于Delphi的写法
private bool bl_logined_weijing = false;
private string uid;
private HttpResult result;
HttpItem item;
string html;
if (!bl_logined_weijing)
{
if (httpWeijing == null)
httpWeijing = new THttpHelper();
item = new HttpItem()
{
URL = "http://www.pinnaclesports.com/",//http://www.pinnaclesports.com/default.aspx/GetContentHTML?culture='zh-TW'
Method = "get",
};
result = httpWeijing.GetHtml(item);
html = result.Html;
string str_1 = TPubFun.CopyStrEx(html, "__PREVIOUSPAGE", "value=\"", "\"", false);
string str_2=TPubFun.CopyStrEx(html, "__VIEWSTATE", "value=\"", "\"", false);
string str_PostData = "__EVENTTARGET=ctl00$LF$LB&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=" + str_2+"&__PREVIOUSPAGE="+str_1+
"&ctl00$LDDL=4&ctl00$PSDDL=american&ctl00$MCPH$LF$UserName=ML333632&ctl00$MCPH$LF$Password=DP7336&ctl00$MCPH$LF$LanguageID=4" +
"&ctl00$MCPH$LF$PriceStyle=american&ctl00$MCPH$LF$LinesTypeView=c&ctl00$MCPH$LF$MemberServer=&dvc=d";
str_PostData =
"__EVENTTARGET=ctl00%24LF%24LB&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=%2FwEPDwUKMTMwOTM4MzY1NmRk&__PREVIOUSPAGE=2eoCOYt8-BaH3Fk4TmLAjNDipT_VBAaVYOUq08FQtLoUD6yQNdxYWcgAm6WCzq7jEhWHYHfkfoYqy2Phd4oKcdp4J4U1&ctl00%24LDDL=4&ctl00%24PSDDL=american&ctl00%24MCPH%24LF%24UserName=用户名&ctl00%24MCPH%24LF%24Password=密码&ctl00%24MCPH%24LF%24LanguageID=4&ctl00%24MCPH%24LF%24PriceStyle=american&ctl00%24MCPH%24LF%24LinesTypeView=c&ctl00%24MCPH%24LF%24MemberServer=&dvc=d";
item = new HttpItem()
{
URL = "https://www.pinnaclesports.com/Secure/LoginPage.aspx?destination=sports", //URL 必需项
Encoding = System.Text.Encoding.GetEncoding("gbk"), //URL 可选项 默认为Get
Method = "post", //URL 可选项 默认为Get
Cookie = result.Cookie, //字符串Cookie 直接用第一次GET到的cookie
Referer = "http://www.pinnaclesports.com/", //来源URL 可选项
Postdata = str_PostData, //Post数据
Timeout = 100000, //连接超时时间 可选项默认为100000
ReadWriteTimeout = 30000, //写入Post数据超时时间 可选项默认为30000
UserAgent = "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/5.0)",
//用户的浏览器类型,版本,操作系统 可选项有默认值
ContentType = "application/x-www-form-urlencoded", //返回类型 可选项有默认值
};
result = httpWeijing.GetHtml(item);
string str_url = result.Header.ToString();
str_url = TPubFun.CopyStr(str_url, "Location:", "\r\nSet-Cookie:", false);
item = new HttpItem()
{
URL = "https://www1.pinnaclesports.com/members/canvas.asp",//str_url,
Method = "get",
Cookie = result.Cookie, //字符串Cookie 直接用第一次GET到的cookie
Referer = "http://www.pinnaclesports.com/", //来源URL 可选项
Timeout = 100000, //连接超时时间 可选项默认为100000
ReadWriteTimeout = 30000, //写入Post数据超时时间 可选项默认为30000
UserAgent = "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/5.0)",
ContentType = "application/x-www-form-urlencoded", //返回类型 可选项有默认值
};
result = httpWeijing.GetHtml(item);
html = result.Html;
//cookie = result.Cookie;
rtxt1.Text = html ;
// bl_logined_weijing = true;
}
|
|