http://gall.dcinside.com/board/view/?id=programming&no=608623&page=1&search_pos=&s_type=search_all&s_keyword=c#

예전에 글자 깨짐으로 질문했다가 변변한 답변은 못받고 헤메다가 구글링을하여 결국 해결방법을 알아냈습니다!!! 갓 구글링...


string source_url = "주소입력"


            WebClient wc = new WebClient();

            Stream st = wc.OpenRead(source_url);

            Encoding enc = Encoding.GetEncoding("utf-8");

            StreamReader sr = new StreamReader(st, enc);

            string html = sr.ReadToEnd();

            


            string _html = wc.DownloadString(source_url);


            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();

            doc.LoadHtml(html);


            HtmlAgilityPack.HtmlNodeCollection _nodes = doc.DocumentNode.SelectNodes("//div[@class='a1wrp']//h3//a[@href]");


            var nodes = _nodes;


            string value = "";


            int i = 0;

            string[] xx = new string[40];


            var nodes1 = _nodes;

            foreach (var node in nodes1)

            {

                value = node.InnerText + "\r\n";

                textBox1.Text += value.ToString();

                xx[i] = value.ToString();

                //System.Threading.Thread.Sleep(100);

                i++;

            }

이렇게 하니까 정상적으로 출력이 되더군요


제가 저 처음에 쓴 방법은

사이트 URL에서 HTML 파일은 다운 받은다음 그 HTML 파일을 로드한다음 파싱하는 방법인데 왜 위에 코드는 정상적으로 출력되고 제가 처음에 쓴 방법은 글자가 깨지는 걸까요?