.Net/.Net

[.Net] 웹 자동화 구현 클래스

뚱2 2013. 1. 9. 11:22

.Net에서 WebBrowser 컨트롤을 임포트 해서 해결할수도 있고

 

좀더 아래 로우레벨로 내려가서 해결할수도 있습니다.

 

링크 (WebClient) : http://msdn.microsoft.com/ko-kr/library/system.net.webclient(v=vs.80).aspx

using System;
using System.Net;
using System.IO;

public class Test
{
    public static void Main (string[] args)
    {
        if (args == null || args.Length == 0)
        {
            throw new ApplicationException ("Specify the URI of the resource to retrieve.");
        }
        WebClient client = new WebClient ();

        // Add a user agent header in case the
        // requested URI contains a query.

        client.Headers.Add ("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

        Stream data = client.OpenRead (args[0]);
        StreamReader reader = new StreamReader (data);
        string s = reader.ReadToEnd ();
        Console.WriteLine (s);
        data.Close ();
        reader.Close ();
    }
}

 

이벤트 (DownloadProgressChanged) : http://msdn.microsoft.com/ko-kr/library/system.net.webclient.downloadprogresschanged(v=vs.80).aspx 


링크 (WebRequest) : http://msdn.microsoft.com/ko-kr/library/system.net.webrequest(v=vs.95).aspx