本帖最后由 ofaith 于 2022-9-6 18:50 编辑
[C#] 纯文本查看 复制代码 HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
Method = "GET",
KeepAlive = true,
URL = "https://30238104-qt.nn888.co/",
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36",
};
HttpResult result = http.GetHtml(item);
string location = result.Header["Location"];
Console.WriteLine("Location = " + location);
http = new HttpHelper();
item = new HttpItem()
{
Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
Method = "GET",
KeepAlive = true,
URL = "https://30238104-qt.nn888.co" + location,
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36",
};
result = http.GetHtml(item);
string initCookie = result.Cookie;
Console.WriteLine("initCookie = " + initCookie);
item = new HttpItem()
{
Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
Method = "GET",
KeepAlive = true,
Cookie = initCookie,
URL = "https://30238104-qt.nn888.co/",
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36",
};
result = http.GetHtml(item);
Console.WriteLine("result.StatusCode = " + result.StatusCode);
直接贴代码,最后一次请求的result.StatusCode会返回302,不知道什么原因,请各位大佬指教!
|