|
1金钱
//获取cookie
HttpHelper httphelper = new HttpHelper();
HttpItem httpitem = new HttpItem();
HttpResult httpresult = new HttpResult();
httpitem.URL = "http://library.ysu.edu.cn/middle.aspx";
IDictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("username", username);
parameters.Add("psw", password);
httpitem.PostdataByte = GetPostdata(parameters);
httpitem.Referer = "http://library.ysu.edu.cn/";
httpitem.Host = "library.ysu.edu.cn";
httpitem.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko";
httpresult = httphelper.GetHtml(httpitem);
string cookie = httpresult.Cookie.Replace("; path=/; HttpOnly", "");
//登陆后页面
HttpItem item = new HttpItem()
{
URL = "http://library.ysu.edu.cn/",
Method = "get",
Cookie = cookie,
Referer="http://library.ysu.edu.cn/",
Host = "library.ysu.edu.cn",
UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko",
};
HttpHelper http = new HttpHelper();
HttpResult result = http.GetHtml(item);
string html = result.Html;
textBox1.Text = html + "\r\n";
textBox2.Text = cookie;
bool is_true = html.Contains("欢迎您");
if (is_true) //登陆成功
{
MessageBox.Show("ok");
}
结果没有,,,ok 求大神,感激不尽
|
|