Esempio n. 1
0
        public static void OpenIE()
        {
            Proxies.UnsetProxy();
            List<string> ipList = new List<string>();
            string ids = null;
            bool isCompleted = false;
            EventHandlers everHandlers = new EventHandlers();
            SHDocVw.InternetExplorer ieExplorer = new SHDocVw.InternetExplorer();
            object Empty = 0;
            object URL = "http://hao.360.cn/?src=lm&ls=n1b07c70297";
            ieExplorer.BeforeNavigate2 += new SHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHandler(everHandlers.OnBeforeNavigate2);
            ieExplorer.Visible = true;
            ieExplorer.Navigate2(ref URL, ref Empty, ref Empty, ref Empty, ref Empty);
            ieExplorer.DocumentComplete += delegate
            {
                //var documentClass = ieExplorer.Document;
                //// mshtml.HTMLDocumentClass
                //ids = documentClass.IHTMLDocument2_body.innerHTML;
                isCompleted = true;
            };
            while (true)
            {
                if (isCompleted)
                {
                    break;

                }
            }
            if (isCompleted)
            {
                mshtml.IHTMLDocument2 doc2 = (mshtml.IHTMLDocument2)ieExplorer.Document;
                //mshtml.IHTMLElementCollection inputs = (mshtml.IHTMLElementCollection)doc2.all.tags("INPUT");
                //mshtml.HTMLInputElement input1 = (mshtml.HTMLInputElement)inputs.item("word", 0);
                //input1.value = "刘德华";
                mshtml.IHTMLElementCollection ccCollection = doc2.all.tags("A");

                //mshtml.IHTMLElement element2 = (mshtml.IHTMLElement)ccCollection;   //25新浪,73唯品会
                //int all = ccCollection.length;
                //element2.click();
                int i=0;
            }
            Thread.Sleep(5000);
            ieExplorer.Quit();

            System.Diagnostics.Process[] myProcesses;
            myProcesses = System.Diagnostics.Process.GetProcessesByName("IEXPLORE");
            foreach (System.Diagnostics.Process instance in myProcesses)
            {
                instance.CloseMainWindow();
            }
        }
Esempio n. 2
0
        public static List<string> OperateIE(string url = "")
        {
            Proxies.UnsetProxy();
            List<string> ipList = new List<string>();
            string ids = null;
            bool isCompleted = false;
            EventHandlers everHandlers = new EventHandlers();
            SHDocVw.InternetExplorer ieExplorer = new SHDocVw.InternetExplorer();
            object Empty = 0;
            object URL = "http://vxer.daili666.com/ip/?tid=555950095890637&num=10&ports=80&filter=on";
            ieExplorer.BeforeNavigate2 +=
                new SHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHandler(everHandlers.OnBeforeNavigate2);
            ieExplorer.Visible = false;
            ieExplorer.Navigate2(ref URL, ref Empty, ref Empty, ref Empty, ref Empty);
            ieExplorer.DocumentComplete += delegate
            {
                var documentClass = ieExplorer.Document;
                // mshtml.HTMLDocumentClass
                ids = documentClass.IHTMLDocument2_body.innerHTML;
                isCompleted = true;
            };
            while (true)
            {
                if (isCompleted)
                {
                    break;

                }
            }
            if (ids != null)
            {
                ids = ids.Substring(ids.IndexOf('>') + 1, ids.LastIndexOf('<') - 5);
                StringReader s = new StringReader(ids);

                while (s.Peek() > 0)
                {
                    var s1 = s.ReadLine();
                    ipList.Add(s1);
                }
                s.Close();
            }
            ieExplorer.Quit();
            return ipList;
        }
Esempio n. 3
0
        public void Open(string url)
        {
            //Proxies.UnsetProxy();
            //string ids = null;
            bool isCompleted = false;
            EventHandlers everHandlers = new EventHandlers();
            SHDocVw.InternetExplorer ieExplorer = new SHDocVw.InternetExplorer();
            object Empty = 0;
            object URL = url;
            ieExplorer.BeforeNavigate2 += new SHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHandler(everHandlers.OnBeforeNavigate2);
            ieExplorer.Visible = true;
            ieExplorer.Navigate2(ref URL, ref Empty, ref Empty, ref Empty, ref Empty);
            Timer timer=new Timer(10000);
            timer.AutoReset = false;
            timer.Start();
            timer.Elapsed += delegate { isCompleted = true; };
            ieExplorer.DocumentComplete += delegate
            {
                //var documentClass = ieExplorer.Document;
                //// mshtml.HTMLDocumentClass
                //ids = documentClass.IHTMLDocument2_body.innerHTML;
                isCompleted = true;
            };
            while (true)
            {
                if (isCompleted)
                {
                    break;

                }
            }
            if (isCompleted)
            {
                try
                {
                    if (url.Contains("2345"))
                    {
                        mshtml.IHTMLDocument2 doc2 = (mshtml.IHTMLDocument2) ieExplorer.Document;
                        mshtml.IHTMLElementCollection inputs = (mshtml.IHTMLElementCollection) doc2.all.tags("INPUT");
                        mshtml.HTMLInputElement input1 = (mshtml.HTMLInputElement) inputs.item("word", 0);
                        input1.value = "刘德华";
                        mshtml.IHTMLElementCollection ccCollection = doc2.all.tags("A");
                        int random = (new Random()).Next(25, 73); //25新浪,73唯品会
                        mshtml.IHTMLElement element2 = (mshtml.IHTMLElement) ccCollection.item("2", random);
                        element2.click();
                    }
                    if (url.Contains("360"))
                    {
                        mshtml.IHTMLDocument2 doc2 = (mshtml.IHTMLDocument2) ieExplorer.Document;
                        mshtml.IHTMLElementCollection ccCollection = doc2.all.tags("A");
                        int random = (new Random()).Next(70, 140);
                        mshtml.IHTMLElement element2 = (mshtml.IHTMLElement) ccCollection.item(random);
                        element2.click();
                    }
                }
                catch (Exception)
                {

                }
                finally
                {
                    Thread.Sleep(7000);
                    ieExplorer.Quit();

                    System.Diagnostics.Process[] myProcesses;
                    myProcesses = System.Diagnostics.Process.GetProcessesByName("IEXPLORE");
                    foreach (System.Diagnostics.Process instance in myProcesses)
                    {
                        instance.CloseMainWindow();
                    }
                    CleanIECookics.CleanCookie();
                    Thread.Sleep(7000);
                }
            }
        }