[C#] 纯文本查看 复制代码 string username = "471555519@qq.com";// ldr.Cells[0].Value.ToString();
string password = "wgy201314";//dr.Cells[2].Value.ToString();
// string ls_yyurl=(string)parms[1];
string Cookies = "";// (string)ldr.Cells[5].Value;
HttpItem itemSign = new HttpItem() //获取_sign
{
URL = "https://account.xiaomi.com/pass/serviceLogin",
};
HttpHelper http = new HttpHelper();
HttpResult httpresult = http.GetHtml(itemSign);
Cookies = httpresult.Cookie;
string CallBack = System.Uri.EscapeDataString(Regex.Match(httpresult.Html, "(?<=callback = encodeURIComponent\\(\").*\"").Value.ToString().Replace("\"", ""));
string SID = System.Uri.EscapeDataString(Regex.Match(httpresult.Html, "(?<=sid = encodeURIComponent\\(\").*\"").Value.ToString().Replace("\"", ""));
string QS = System.Uri.EscapeDataString(Regex.Match(httpresult.Html, "(?<=qs = encodeURIComponent\\(\").*\"").Value.ToString().Replace("\"", ""));
string SIGN = System.Uri.EscapeDataString(Regex.Match(httpresult.Html, "(?<=sign = encodeURIComponent\\(\").*\"").Value.ToString().Replace("\"", ""));
string HIDDEN = System.Uri.EscapeDataString(Regex.Match(httpresult.Html, "(?<=hidden = encodeURIComponent\\(\").*\"").Value.ToString().Replace("\"", ""));
string FrameSrc = System.Uri.EscapeDataString(Regex.Match(httpresult.Html, "(?<=var iframeSrc = \").*\"").Value.ToString().Replace("\"", ""));
HttpItem item = new HttpItem() //登陆Post
{
URL = "https://account.xiaomi.com/pass/serviceLoginAuth2",
Method = "POST",
Referer = "https://account.xiaomi.com/pass/serviceLogin",
ContentType = "application/x-www-form-urlencoded",
Postdata = string.Format("passToken={0}&user={1}&pwd={2}&callback={3}&sid={4}&qs={5}&hidden={6}&_sign={7}", "", username, password, CallBack, SID, QS, HIDDEN, SIGN)
};
HttpResult result = http.GetHtml(item);
item = new HttpItem()
{
URL = result.Header["Location"]
};
result = http.GetHtml(item);
string cookie = result.Cookie;
item = new HttpItem()
{
URL = result.Header["Location"],
Referer = item.URL,
Cookie = cookie
};
result = http.GetHtml(item);//成功到个人账户页面
item = new HttpItem()
{
URL = result.Header["Location"],
Referer = item.URL,
Cookie = cookie
};
result = http.GetHtml(item);//成功到个人账户页面
这样才是真正的登录成功啊
|