Доброе утро! На эту тему было сделано много сообщений, но ни одна из них не сработала.
Я хотел бы получить исходный код этого сайта: https://www.curseforge.com/minecraft/mc-mods
Но это не работает; webclient возвращает ошибку: Ошибка 403: Запрещено
Вот мой код:
string urlAddress = "https://www.curseforge.com/minecraft/mc-mods";
WebClient webClient = new WebClient();
webClient.DownloadString(urlAddress);
И вот что я пробовал:
string urlAddress = "https://www.curseforge.com/minecraft/mc-mods";
WebClient webClient = new WebClient();
webClient.Headers.Add("User-Agent: Other"); // or client.Headers.Add("user-agent", " Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0");
webClient.DownloadString(urlAddress);
-
string urlAddress = "https://www.curseforge.com/minecraft/mc-mods";
using (WebClient wc = new WebClient())
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
wc.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.BypassCache);
wc.Headers.Add("Cache-Control", "no-cache");
wc.Encoding = Encoding.UTF8;
string result = wc.DownloadString(urlAddress);
}
-
string urlAddress = "https://www.curseforge.com/minecraft/mc-mods";
HttpResponseMessage response = await client.GetAsync(urlAddress);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
и все еще полно кода.
В любом случае, мне действительно нужно решение. Если кто-то может мне помочь, было бы круто :) 1024 *