错误403禁止HTTP请求下载HTML

时间:2019-03-21 13:25:52

标签: c# http httpclient http-status-code-403

我需要一些帮助来从网站下载数据

我确实知道我的代码出了什么问题,我看到了很多帮助,但我无法解决

我试图访问站点数据以获取经济日历信息,

这是我的代码:

namespace Adquire_dados
{
    class Program
    {
        private static object webRequest;

        static void Main(string[] args)
        {
            GetRequest("https://br.investing.com/economic-calendar/");
            Console.ReadLine();

        }

        async static void GetRequest(string url)
        {
            using (HttpClient client = new HttpClient())
            {
                CookieContainer cookies = new CookieContainer();
                HttpClient httpClient = new HttpClient();
                HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, url);


                using (HttpResponseMessage httpResponse = await client.GetAsync(url))
                {
                    using (HttpContent content = httpResponse.Content)
                    {
                        string mycontent = await content.ReadAsStringAsync();
                        Console.WriteLine(mycontent);
                    }
                }
            }

        }
    }
}

以及我得到的结果:

<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.14.0</center>
</body>
</html>

感谢您的帮助!

0 个答案:

没有答案