登录网址: https://account.mail.ru/login
***********************注:本文仅作学习交流,如有侵权,请私信删除。
1. 访问登录页面: 获取cookie值
private bool GetIndex()
{
string url = "https://account.mail.ru/login";
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Add("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3");
request.Headers.Add("accept-encoding", "gzip, deflate, br");
request.Headers.Add("accept-language", "zh-CN,zh;q=0.9");
request.Headers.Add("user-agent", UserAgent);
HttpResponseMessage response = client.SendAsync(request).Result;
if (!response.IsSuccessStatusCode)
{
Msg = "网络错误";
return false;
}
List<string> setCookie = response.Headers.GetValues("set-cookie").ToList();
cookies = ToolData.getCookies(setCookie);
actToken = ToolData.getCookieValue(setCookie, "act");
return true;
}
2. 输入账号: 验证账号是否存在
private bool InputAccount()
{
string url = "https://auth.mail.ru/api/v1/pushauth/info";
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url);
request.Headers.Add("accept", "*/*");
request.Headers.Add("accept-encoding", "gzip, deflate, br");
request.Headers.Add("accept-language", "zh-CN,zh;q=0.9");
request.Headers.Add("Host", "auth.mail.ru");
request.Headers.Add("Origin", "https://account.mail.ru");
request.Headers.Add("Referer", "https://account.mail.ru/login");
request.Headers.Add("cookie", cookies);
request.Headers.Add("user-agent", UserAgent);
string data = $"email={HttpUtility.UrlEncode(email)}&utm=&htmlencode=false&login={HttpUtility.UrlEncode(email)}";
request.Content = new StringContent(data);
request.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/x-www-form-urlencoded");
request.Content.Headers.ContentLength = data.Length;
HttpResponseMessage response = client.SendAsync(request).Result;
if (response.IsSuccessStatusCode)
{
string content = response.Content.ReadAsStringAsync().Result;
JObject json = JObject.Parse(content);
if (Convert.ToBoolean(json.SelectToken("body.exists")))
{
return InputPwd();
}
}
Msg = "该账号不存在";
return false;
}
3. 输入账号和密码: 确认账号和密码是否正确
private