반응형

참조 추가 Microsoft Internet Controls(SHDocVw)와 Microsoft.mshtml 를 하고

 

using System.Runtime.InteropServices;

using SHDocVw;
using mshtml;

한다.

 

그 후

 

InternetExplorer ex = new InternetExplorer();      
ex.Visible = true;
Object obj = null;

ex.Navigate("http://cyworld.com", ref obj, ref obj, ref obj, ref obj);

 

위와 같이 익스플로러를 실행시키고 (싸이월드로)

굳이 익스플로러가 아니더라도.. WebBrowser를 사용하셔도 됩니다.

 

private void button3_Click(object sender, EventArgs e)
        {
            IHTMLDocument2 hd;
            hd = (IHTMLDocument2)ex.Document;
            IHTMLElementCollection hCollection = (IHTMLElementCollection)hd.all;
            object obj = "input";                    //input 태그 찾으려고
            IHTMLElementCollection he = (IHTMLElementCollection)hCollection.tags(obj);
            foreach (IHTMLElement helem in he)
            {
                if (helem.getAttribute("name", 0) != null)
                {
                    if (helem.getAttribute("name", 0).ToString() == "email")    //소스를 보고 name속성의 값을 적는다, 아이디 항목
                    {
                        helem.setAttribute("value", (Object)"아이디", 0);       //value 속성에 아이디를 대입
                    }

                    if (helem.getAttribute("name", 0).ToString() == "passwd")
                    {
                        helem.setAttribute("value", (Object)"비밀번호", 0);
                    }
                }
            }
        }

 

 

반응형

+ Recent posts