Пример #1
0
        public void DownloadDocument(CrawlerSession Session)
        {
            if (CrawlerStatus != Status.ScanPending)
            {
                return;
            }

            try
            {
                CrawlerStatus = Status.ScanInProgress;

                string Hostname; bool UseSsl;
                BuildHostname(out Hostname, out UseSsl);
                string RelativePath = Href.Split(new string[] { Hostname }, StringSplitOptions.None)[1];

                HttpConnection TmpConnection = new HttpConnection();
                TmpConnection.StartConnection(Hostname, UseSsl);

                List <byte> Data;
                TmpConnection.ExecuteRequest(RelativePath, out Data);
                TmpConnection.CloseConnection();

                CrawlerStatus = ParseDocument(Data) ? Status.ScanFinished : Status.ScanFailed;
            }
            catch { Errmsg = "tcp error"; CrawlerStatus = Status.ScanFailed; }
            OnDocumentParsed(this);
        }
Пример #2
0
        private void ButtonBeginCrawling_Click(object sender, EventArgs e)
        {
            ButtonBeginCrawling.Enabled = false;
            ListboxLog.Items.Clear();

            Session = new CrawlerSession();
            Session.OnCrawlerProgress += HandleOnCrawlerProgress;
            Session.OnCrawlerFinished += HandleOnCrawlerFinished;
            Session.BeginSession(Cfg);
        }
Пример #3
0
 private void HandleOnCrawlerProgress(CrawlerSession Session, int DocumentsParsed, int DocumentsLeft)
 {
     Invoke(new Action(() =>
     {
         ProgressbarCrawler.Maximum = DocumentsParsed + DocumentsLeft;
         ProgressbarCrawler.Value   = Math.Min(ProgressbarCrawler.Maximum, DocumentsParsed + 1);
         ProgressbarCrawler.Value   = Math.Max(DocumentsParsed, 0);
         ListboxLog.Items.Clear();
         ListboxLog.Items.Add(
             string.Format("{0}/{1} documents parsed",
                           DocumentsParsed.ToString(),
                           (DocumentsParsed + DocumentsLeft).ToString()));
     }));
 }
Пример #4
0
 private void HandleOnCrawlerFinished(CrawlerSession Session)
 {
     Invoke(new Action(() =>
     {
         ListboxLog.Items.Clear();
         if (!Session.PrintCrawlSessionToXml())
         {
             MessageBox.Show("Could not create XML file.");
         }
         PrintDoc(Session.GetRootDocument());
         this.Session = null;
         ButtonBeginCrawling.Enabled = true;
         ProgressbarCrawler.Value    = ProgressbarCrawler.Maximum;
     }));
 }