[c#]네이버 html 다운로드 받기 [콘솔]

Posted by 슈퍼너드 리보
2020. 7. 25. 19:23 프로그래밍/C#
반응형

네이버 html을 c#으로 html을 다운로드 받아보겠습니다.. WebClient만 알면 쉽게 만들어 볼 수 있습니다.



소스코드

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;

namespace NaverHtml
{
    class NaverHtml
    {
        static void Main(string[] args)
        {
            WebClient z = new WebClient();
            z.Encoding = Encoding.UTF8;
            z.DownloadStringAsync(new Uri("http://www.naver.com"));
            z.DownloadStringCompleted += DownloadStringCompleted;
            while (true)
            {

            }
        }

        private static void DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            Console.WriteLine(e.Result);
        }
    }
}

콘솔창에서 출력되는 네이버 html

네이버의 html들이 콘솔창에 출력되는걸 확인 할 수 있습니다. 이를 이용하면 파싱하는데 사용 할 수 있습니다.


반응형