예제 #1
0
        private void VBACsEXWB_DocumentComplete(object sender, DocumentCompleteEventArgs e)
        {
            if (e.url.ToLower() == "about:blank")
            {
                m_IsNavigationCompleted = true;

                //发出提示
                lock (navigatelocker)
                {
                    Monitor.Pulse(navigatelocker);
                }
                return;
            }

            if (e.istoplevel)
            {
                log.Debug("DocumentComplete::TopLevel is TRUE===>" + e.url);
                m_IsNavigationCompleted = true;
                //发出提示
                lock (navigatelocker)
                {
                    Monitor.Pulse(navigatelocker);
                }
            }
            else
            {
                log.Debug("DocumentComplete::TopLevel is FALSE===>" + e.url);
            }
        }
예제 #2
0
    protected void OnDocumentComplete(object ppDisp, object url)
    {
        EventHandler <DocumentCompleteEventArgs> h = DocumentComplete;
        DocumentCompleteEventArgs args             = new DocumentCompleteEventArgs(ppDisp, url);

        if (null != h)
        {
            h(this, args);
        }
        //Pass the ppDisp chosen back out to the events
        ppDisp = args.PPDisp;
        //I think url is readonly
    }
예제 #3
0
        /*
         * When e.isTopLevel parameter of DocumentComplete is true, it means that the main document has finished loading whether we have a frameset or not.
         * In a frameset page, DocumentComplete is fired for every frame. In the case of a frame, e.isTopLevel is false, meanning that the document is still loading.
         * When all frames have been loaded then the DocumentComplete is fired for the main document signaling that the document has finished loading which is recognized when isTopLevel is true. There is no need to use timers to find out when the page has fully loaded.
         */
        private void WebBrower_DocumentComplete(object sender, DocumentCompleteEventArgs e)
        {
            if (e.url.ToLower() == "about:blank")
            {
                return;
            }
            cEXWB pWB = sender as cEXWB;

            if (e.istoplevel)
            {
                IsDocumentFinish = true;
                //Logger.Log(LogLevel.Info, string.Format("DocumentComplete,Url:{0},时间:{1}", e.url,DateTime.Now));
            }
            else if (pWB != null && pWB.MainDocumentFullyLoaded) // a frame naviagtion within a frameset
            {
                IsDocumentFinish = true;
                //Logger.Log(LogLevel.Info, string.Format("MainDocumentFullyLoaded,Url:{0},时间:{1}", e.url, DateTime.Now));
            }
            else
            {
                //log.Debug("DocumentComplete::TopLevel is FALSE===>" + e.url);
            }
        }
예제 #4
0
        private void WebBrower_DocumentComplete(object sender, DocumentCompleteEventArgs e)
        {
            if (e.url.ToLower() == "about:blank")
            {
                return;
            }

            cEXWB pWB = sender as cEXWB;

            if (e.istoplevel)
            {
                IsDocumentFinish = true;
                Html             = pWB.DocumentSource;
                htmlDocument     = HtmlAgilityPackHelper.GetHtmlDocument(pWB.DocumentSource);
                //Stopwatch sw=new Stopwatch();
                //sw.Start();
                //LoadHtmlTree();
                //sw.Stop();
                Stopwatch sw1 = new Stopwatch();
                sw1.Start();
                BuildTree3();
                sw1.Stop();
                richTextBox.Text += string.Format("DOM树构建时间{0}毫秒", sw1.ElapsedMilliseconds) + "\n";
                //MessageBox.Show(sw1.ElapsedMilliseconds.ToString());
                //Logger.Log(LogLevel.Info, string.Format("DocumentComplete,Url:{0},时间:{1}", e.url,DateTime.Now));
            }
            else if (pWB != null && pWB.MainDocumentFullyLoaded) // a frame naviagtion within a frameset
            {
                IsDocumentFinish = true;
                //Logger.Log(LogLevel.Info, string.Format("MainDocumentFullyLoaded,Url:{0},时间:{1}", e.url, DateTime.Now));
            }
            else
            {
                //log.Debug("DocumentComplete::TopLevel is FALSE===>" + e.url);
            }
        }
 protected virtual void Browser_DocumentComplete(object sender, DocumentCompleteEventArgs e)
 {
 }
예제 #6
0
 protected void OnDocumentComplete(object ppDisp, object url)
 {
     EventHandler<DocumentCompleteEventArgs> h = DocumentComplete;
     DocumentCompleteEventArgs args = new DocumentCompleteEventArgs(ppDisp, url);
     if (null != h)
     {
         h(this, args);
     }
     //Pass the ppDisp chosen back out to the events
     ppDisp = args.PPDisp;
     //I think url is readonly
 }
예제 #7
0
        private void cEXWB1_DocumentComplete(object sender, DocumentCompleteEventArgs e)
        {
            //Your Local Australian Business Directory
            if (j == 29)
            {
                MessageBox.Show("Page is 29 completed");
            }
            if ((i == 1) && (this.cEXWB1.DocumentTitle.ToString().Contains("Your Local Australian Business Directory")))
            {
                this.cEXWB1.Navigate2("https://www.yellowpages.com.au/search/listings?clue=Real+Estate+Listing+Services&locationClue=All+States&pageNumber=" + j + "&referredBy=www.yellowpages.com.au&&eventType=pagination");
                // this.cEXWB1.Navigate2("https://www.yellowpages.com.au/search/listings?clue=Real+Estate+Sales+Advisory+Services&locationClue=All+States&pageNumber=" + j + "&referredBy=www.yellowpages.com.au&&eventType=pagination");
                //this.cEXWB1.Navigate2("https://www.yellowpages.com.au/search/listings?clue=Real+Estate+Development&locationClue=All+States&pageNumber="+j+"&referredBy=www.yellowpages.com.au&&eventType=pagination");
                //this.cEXWB1.Navigate2("https://www.yellowpages.com.au/search/listings?clue=Real+Estate+Auctioneers&locationClue=All+States&pageNumber="+j+"&referredBy=www.yellowpages.com.au&&eventType=pagination");
                //this.cEXWB1.Navigate2("https://www.yellowpages.com.au/search/listings?clue=commercial+real+estate+agents&locationClue=All+States&pageNumber=" + j + "&referredBy=www.yellowpages.com.au&&eventType=pagination");
                //this.cEXWB1.Navigate2("https://www.yellowpages.com.au/search/listings?clue=Real+Estate+Agents&eventType=pagination&locationClue=All+States&openNow=false&pageNumber="+j+"&referredBy=www.yellowpages.com.au&&state=NSW");
                //this.cEXWB1.Navigate2("https://www.yellowpages.com.au/search/listings?clue=Truline+Australia+Pty+Ltd&locationClue=All+States&lat=&lon=&selectedViewMode=list");
                data = this.cEXWB1.DocumentSource.ToString();
                i++;
            }
            else if (i == 2)
            {
                #region comment2
                //IfacesEnumsStructsClasses.IHTMLElementCollection data = this.cEXWB1.GetElementsByTagName(false,"div");
                //foreach (IHTMLElement2 ce in data)
                //{
                //    IHTMLElement cee = (IHTMLElement)ce;
                //    // object obj = cee.getAttribute("href", 1);
                //    //collapser__link collapser__link--dense
                //   // object obj = cee.getAttribute("class", 1);

                //     if (cee.outerHTML.ToString().Contains("search-results search-results-data listing-group"))
                //    {
                //      //  cee.click();
                //        // break;
                //    }

                //    //MessageBox.Show(cee.innerHTML);
                //}
                #endregion
                HtmlAgilityPack.HtmlDocument h1 = new HtmlAgilityPack.HtmlDocument();
                h1.LoadHtml(this.cEXWB1.DocumentSource.ToString());
                var datas = h1.DocumentNode.SelectSingleNode("//html/body/div[1]/div/div[3]/div/div/div[2]/div/div[2]/div[2]/div");
                //class="cell in-area-cell find-show-more-trial   middle-cell"
                var filter1 = datas.SelectSingleNode("//div[@class='cell in-area-cell find-show-more-trial   middle-cell']");
                foreach (var Filter in datas.SelectNodes("//div[@class='cell in-area-cell find-show-more-trial   middle-cell']"))
                {
                    var items = Filter;
                    for (int k = 0; k < items.SelectNodes("//a[@class='listing-name']").Count; k++)
                    {
                        Address     = string.Empty;
                        Name        = string.Empty;
                        PhoneNumber = string.Empty;
                        Email       = string.Empty;
                        website     = string.Empty;
                        #region comment1
                        ////class="listing-name"
                        //foreach (var item2 in items.SelectNodes("//a"))
                        //{
                        //}
                        //<span class="contact-text">(02) 9868 3333</span>
                        //class="contact contact-main contact-url " website get href value
                        //class="contact contact-main contact-email " get data-email=
                        #endregion

                        try
                        {
                            Name = items.SelectNodes("//a[@class='listing-name']")[k].InnerHtml.ToString();
                        }
                        catch (Exception ex)
                        {
                            Name = "";
                        }

                        try
                        {
                            Address = items.SelectNodes("//p[@class='listing-address mappable-address mappable-address-with-poi']")[k].InnerHtml.ToString();
                        }
                        catch (Exception ex)
                        {
                            try
                            {
                                Address = items.SelectNodes("//p[@class='listing-address mappable-address']")[k].InnerHtml.ToString();
                            }
                            catch (Exception ex1)
                            {
                                try
                                {
                                    Address = items.SelectNodes("//p[@class='listing-heading']")[k].InnerText.ToString();
                                }
                                catch (Exception ex2)
                                {
                                    Address = "";
                                }
                            }
                        }

                        try
                        {
                            PhoneNumber = items.SelectNodes("//a[@class='click-to-call contact contact-preferred contact-phone ']")[k].InnerText.ToString().Replace("\n", "").Trim();
                        }
                        catch (Exception ex)
                        {
                            PhoneNumber = "";
                        }

                        try
                        {
                            website = items.SelectNodes("//a[@class='contact contact-main contact-url ']")[k].GetAttributeValue("href", "").ToString();
                        }
                        catch (Exception ex)
                        {
                            website = "";
                        }
                        try
                        {
                            Email = items.SelectNodes("//a[@class='contact contact-main contact-email ']")[k].GetAttributeValue("data-email", "").ToString();
                        }
                        catch (Exception ex)
                        {
                            Email = "";
                        }
                        StringBuilder str = new StringBuilder();
                        LogData(Name + "\t" + Address + "\t" + PhoneNumber + "\t" + website + "\t" + Email);
                    }
                    break;
                }
                Console.WriteLine(j + " pages completed");
                j++;
                //this.cEXWB1.Navigate2("https://www.yellowpages.com.au/search/listings?clue=Real+Estate+Development&locationClue=All+States&pageNumber=" + j + "&referredBy=www.yellowpages.com.au&&eventType=pagination");
                // this.cEXWB1.Navigate2("https://www.yellowpages.com.au/search/listings?clue=Real+Estate+Agents&eventType=pagination&locationClue=All+States&openNow=false&pageNumber=" + j + "&referredBy=www.yellowpages.com.au&&state=NSW");
                //this.cEXWB1.Navigate2("https://www.yellowpages.com.au/search/listings?clue=commercial+real+estate+agents&locationClue=All+States&pageNumber=" + j + "&referredBy=www.yellowpages.com.au&&eventType=pagination");
                //this.cEXWB1.Navigate2("https://www.yellowpages.com.au/search/listings?clue=Real+Estate+Auctioneers&locationClue=All+States&pageNumber=" + j + "&referredBy=www.yellowpages.com.au&&eventType=pagination");
                //this.cEXWB1.Navigate2("https://www.yellowpages.com.au/search/listings?clue=Real+Estate+Sales+Advisory+Services&locationClue=All+States&pageNumber=" + j + "&referredBy=www.yellowpages.com.au&&eventType=pagination");
                this.cEXWB1.Navigate2("https://www.yellowpages.com.au/search/listings?clue=Real+Estate+Listing+Services&locationClue=All+States&pageNumber=" + j + "&referredBy=www.yellowpages.com.au&&eventType=pagination");
            }
        }