不多说了直接上代码: [C#] 纯文本查看 复制代码 public static string checkHotmail(string mail) { //1.取cookie
string hotmailCookie = "";
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "https://signup.live.com/signup",
Method = "get",
};
HttpResult result = http.GetHtml(item);
string uaid = "";
string location = "";
//返回的Html内容
hotmailCookie = result.Cookie;
uaid = getCenerString(location, "uaid%3D", "%26lic");
item = new HttpItem()
{
URL = location,
Method = "get",
Cookie = hotmailCookie,
Allowautoredirect = true,//是否根据301跳转 可选项
};
result = http.GetHtml(item);
//返回的Html内容
if (result.StatusCode == System.Net.HttpStatusCode.OK)
{
//Console.WriteLine("cookie2:" + result.Cookie);
hotmailCookie = hotmailCookie + "," + result.Cookie;
}
else {
return "";
}
item = new HttpItem()
{
URL = "https://signup.live.com/API/CheckAvailableSigninNames",
Method = "POST",//URL 可选项 默认为Get
Postdata = "{\"signInName\":\"jxfgoodboy@outlook.com\",\"isEasiCheck\":false,\"uaid\":\"" + uaid + "\",\"uiflvr\":1001,\"scid\":100118,\"hpgid\":200225}",
Referer = "https://signup.live.com/signup.aspx?uaid=" + uaid + "&lic=1",
ContentType = "application/x-www-form-urlencoded; charset=UTF-8",
Cookie = hotmailCookie,
};
result = http.GetHtml(item);
//返回的Html内容
if (result.StatusCode == System.Net.HttpStatusCode.OK)
{
Console.WriteLine(mail + "==》:" + result.Html);
}
else
{
return "无效:取Cookie失败";
}
return "";
}
private static string getCenerString(string str, string first, string end)
{
Regex rg = new Regex("(?<=(" + first + "))[.\\s\\S]*?(?=(" + end + "))", RegexOptions.Multiline | RegexOptions.Singleline);
return rg.Match(str).Value;
}
最后返回的结果:[C#] 纯文本查看 复制代码 {"error":{"code":"6001","data":"","showError":true,"stackTrace":""}}
难道是HttpHelper对https支持不好?望大神指点一下。
|