|
本帖最后由 方家河农夫 于 2014-1-12 16:06 编辑
具体代码如下
HttpItem itemSign = new HttpItem() //获取_sign
{
URL = "https://account.xiaomi.com/pass/serviceLogin?tmp=" + DateTime.Now.ToString("yyyyMMddHHmmss"),
};
HttpHelper helperSign = new HttpHelper();
HttpResult resultSign = helperSign.GetHtml(itemSign);//成功获取
string _sign = System.Uri.EscapeDataString(Regex.Match(resultSign.Html, "(?<=sign = encodeURIComponent\\(\").*\"").Value.ToString().Replace("\"", ""));
xmdata.CallBack = System.Uri.EscapeDataString(Regex.Match(resultSign.Html, "(?<=callback = encodeURIComponent\\(\").*\"").Value.ToString().Replace("\"", ""));
xmdata.SID = System.Uri.EscapeDataString(Regex.Match(resultSign.Html, "(?<=sid = encodeURIComponent\\(\").*\"").Value.ToString().Replace("\"", ""));
xmdata.QS = System.Uri.EscapeDataString(Regex.Match(resultSign.Html, "(?<=qs = encodeURIComponent\\(\").*\"").Value.ToString().Replace("\"", ""));
xmdata.SIGN = System.Uri.EscapeDataString(Regex.Match(resultSign.Html, "(?<=sign = encodeURIComponent\\(\").*\"").Value.ToString().Replace("\"", ""));
xmdata.HIDDEN = System.Uri.EscapeDataString(Regex.Match(resultSign.Html, "(?<=hidden = encodeURIComponent\\(\").*\"").Value.ToString().Replace("\"", ""));
xmdata.FrameSrc = System.Uri.EscapeDataString(Regex.Match(resultSign.Html, "(?<=var iframeSrc = \").*\"").Value.ToString().Replace("\"", ""));
}
string cookies = resultSign.Cookie;
HttpItem itemLogin = new HttpItem() //登陆Post
{
Allowautoredirect = false,
URL = "https://account.xiaomi.com/pass/serviceLoginAuth2",
Method = "POST",
Cookie = cookies,
Referer = "https://account.xiaomi.com/pass/userInfo",
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}", xmdata.PassToken, username, password, xmdata.CallBack, xmdata.SID, xmdata.QS, xmdata.HIDDEN, xmdata.SIGN)
};
HttpHelper helperLogin = new HttpHelper();
HttpResult resultLogin = helperLogin.GetHtml(itemLogin);//成功登陆
cookies += ";" + resultLogin.Cookie;
itemLogin = new HttpItem()
{
Allowautoredirect = false,
URL = "https://account.xiaomi.com/pass/userInfo",
Cookie = cookies,
ContentType = "application/x-www-form-urlencoded",
};
resultLogin = helperLogin.GetHtml(itemLogin);//成功到个人账户页面
//----------------------------------------------------------------以下到预约页面一直出错,求告诉帮忙解答
itemLogin = new HttpItem()
{
Allowautoredirect = false,
URL = "http://a.hd.xiaomi.com/register/book/a/26",
Cookie = cookies,
ContentType = "application/x-www-form-urlencoded",
};
resultLogin = helperLogin.GetHtml(itemLogin);//一直出错,页面访问都OK得,不知道什么原因。好像进入死循环一样,helperLogin.GetHtml 获取不到结果。
求大侠指点呀!!!!!!!!!!!!!!!!
补充内容 (2014-1-12 17:14):
string username=“18314045@qq.com",password="wgy201314"; |
|