Example #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();
            }
        }
Example #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;
        }
Example #3
0
        private void IE_Open(String searchEngine)
        {
            SHDocVw.InternetExplorer objIE = new SHDocVw.InternetExplorer(); //オブジェクトを作成
            objIE.Navigate("about:blank");                                   //空ページの表示
            objIE.Visible = true;                                            //IEを表示


            String encodedKeyword = System.Web.HttpUtility.UrlEncode(this.textBox1.Text, System.Text.Encoding.UTF8);

            String targetUrl = searchEngine + encodedKeyword;

            objIE.Navigate(targetUrl);

            //読み込み完了まで待つ
            while (objIE.Busy || objIE.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
            {
                //無処理
                System.Windows.Forms.Application.DoEvents();
                System.Threading.Thread.Sleep(100);
            }

            var ObjHtml = (mshtml.HTMLDocument)objIE.Document;

            var bodys = ObjHtml.getElementsByTagName("body");

            foreach (mshtml.IHTMLElement element in bodys)
            {
                if (element != null)
                {
                    Debug.WriteLine(element.outerHTML);
                }
            }

            System.Threading.Thread.Sleep(5000);

            if (objIE == null)
            {
                objIE.Quit();
            }
        }
Example #4
0
 public static void PRAP_ResetSearch(SHDocVw.InternetExplorer wb, SHDocVw.ShellWindows shells)
 {
     wb.Quit();
     foreach (SHDocVw.InternetExplorer ie in shells)
     {
         if (ie.LocationName == "Search Results")
         {
             wb = IELib.IEGet(shells, "Search Results");
             if (wb != null)
             {
                 mshtml.HTMLDocument wbDoc = wb.Document;
                 foreach (mshtml.IHTMLElement elem in wbDoc.getElementsByTagName("a"))
                 {
                     if (elem.innerText == "Return to Search")
                     {
                         elem.click();
                         IELib.IeWait(ie);
                     }
                 }
             }
         }
     }
 }
Example #5
0
        private void loadPosts()
        {
            try
            {
                error = false;
                posts.Clear();
                int count = 0;
                SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer();
                IE.Visible = false;
                for (int i = (int)Math.Floor(minPage.Value); i <= (int)Math.Floor(maxPage.Value); i++)
                {
                    IE.Navigate(File.ReadAllText("MafiaUrlConfig") + "?pagenum=" + i);
                    while (IE.ReadyState.ToString() != "READYSTATE_COMPLETE")
                    {
                        System.Threading.Thread.Sleep(100);
                    }
                    if (!IE.LocationURL.ToString().Contains("pagenum") && count < 5)
                    {
                        count++;
                        i--;
                    }
                    else if (count >= 5)
                    {
                        MessageBox.Show("Could not connect to forum post. Make sure that you are logged into roll20 on Internet Explorer, and that you have the correct url.");
                        count = 0;
                        posts.Clear();
                        break;
                    }
                    else
                    {
                        var htmlDoc = IE.Document;

                        string content = htmlDoc.body.outerHTML;
                        File.WriteAllText("temporaryHold.html", content);

                        // load snippet
                        HtmlAgilityPack.HtmlDocument htmlSnippet = new HtmlAgilityPack.HtmlDocument();
                        htmlSnippet = LoadHtmlSnippetFromFile();

                        // extract Posts
                        if (ExtractAllPosts(htmlSnippet, i.ToString()) != null)
                        {
                            posts.AddRange(ExtractAllPosts(htmlSnippet, i.ToString()));
                        }
                        else
                        {
                            error = true;
                            posts.Clear();
                            break;
                        }
                    }
                }
                IE.Quit();
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show("Please click on the New Game button in the bottom left of the page to add your game");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            try
            {
                using (StreamWriter sw = File.CreateText("All.html"))
                {
                    sw.WriteLine("<head>");
                    sw.WriteLine("<meta charset='utf-8'>");
                    sw.WriteLine("</head>");
                    sw.WriteLine("<body>");
                    if (!error)
                    {
                        foreach (ForumPost f in posts)
                        {
                            AddToComboBox(f.name);
                            sw.WriteLine("<table style='width:100%'><tr><td><h3><font color='" + dictionary[comboBox1.Items.IndexOf(f.name)] + "'>" + f.name + "</font></h3></td>" + "<td align='right'><h4> Page: " + f.page + "</h4></td></tr>");
                            sw.WriteLine("<h4>" + f.time + "</h4>");
                            sw.WriteLine("<p>" + f.post + "</p>");
                            sw.WriteLine();
                            sw.WriteLine("<hr>");

                        }
                        sw.WriteLine("</body>");
                    }
                    else
                    {
                        sw.WriteLine("<h1>ERROR</h1>");
                        sw.WriteLine("</body>");
                    }
                }
                NavigateWebBrowserThread(di.ToString() + "\\All.html");
                MovePostsToMainThread(posts);
                SetComboBoxToIndexThread(0);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Example #6
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);
                }
            }
        }