public
void
getSetCookie()
{
string
Url =
"https://sso.douyin.com/check_qrconnect/?aid=6383&app_name=douyin_web&device_platform=web&referer=&user_agent=Mozilla%2F5.0+(Windows+NT+6.3%3B+WOW64)+AppleWebKit%2F537.36+(KHTML,+like+Gecko)+Chrome%2F55.0.2883.87+UBrowser%2F6.2.4098.3+Safari%2F537.36&cookie_enabled=true&screen_width=1600&screen_height=900&browser_language=zh-CN&browser_platform=Win32&browser_name=Mozilla&browser_version=5.0+(Windows+NT+6.3%3B+WOW64)+AppleWebKit%2F537.36+(KHTML,+like+Gecko)+Chrome%2F55.0.2883.87+UBrowser%2F6.2.4098.3+Safari%2F537.36&browser_online=true&timezone_name=Asia%2FShanghai&next=https:%2F%2Fcreator.douyin.com%2F&token="
+ token +
"&service=https:%2F%2Fwww.douyin.com%2F&correct_service=https:%2F%2Fwww.douyin.com%2F&is_vcd=1&fp=kesopiod_fB4eRss7_Stsz_434j_AiPQ_6xhtUsqmqpSN"
;
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
request.UserAgent =
"Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1)"
;
request.Referer = Url;
HttpWebResponse response = request.GetResponse()
as
HttpWebResponse;
StreamReader reader =
new
StreamReader(response.GetResponseStream(), Encoding.GetEncoding(
"utf-8"
));
string
html = reader.ReadToEnd();
string
status = Regex.Match(html,
@"""status"":""([\s\S]*?)"""
).Groups[1].Value;
string
redirect_url = Regex.Match(html,
@"""redirect_url"":""([\s\S]*?)"""
).Groups[1].Value;
if
(status ==
"1"
)
{
label1.Text =
"未扫码.."
;
}
else
if
(status ==
"2"
)
{
label1.Text =
"已扫码.."
;
}
else
if
(redirect_url !=
""
)
{
timer1.Stop();
label1.Text =
"登录成功"
;
string
content = response.GetResponseHeader(
"Set-Cookie"
);
Uri uri =
new
Uri(
"http://douyin.com"
);
string
cookies = CookieHelper.GetCookies(content, uri);
string
cookies2 = getSetCookie2(cookies);
textBox1.Text = cookies2 + cookies;
}
reader.Close();
}