dotnetcore爬虫(一)简单获取页面信息

版权声明:版权声明:本文为博主原创文章,转载请附上博文链接! https://blog.csdn.net/qq_36051316/article/details/84872688

我们就不多讲理论了,直接拿出代码,尝试尝试就知道需要用到什么知识了。

毕竟实践是检验真理的唯一标准。

using System;
using System.Net.Http;

namespace dotnetcoreHttpClient
{
    class Program
    {
        static void Main(string[] args)
        {
            HttpClient client = new HttpClient(new HttpClientHandler());
            //获取我们当前网站的dom
            var html = client.GetStringAsync("https://blog.csdn.net/qq_36051316/article/details/84380024").Result.ToString();
            Console.WriteLine("输出网站内容:");
            Console.WriteLine("================华丽分割线==================");
            System.Console.WriteLine(html);
        }
    }
}

猜你喜欢

转载自blog.csdn.net/qq_36051316/article/details/84872688
今日推荐