private void btnStartStop_Click(object sender, System.EventArgs e) { statusBar.Text = "Processed Uri: " + txtUri.Text; btnStartStop.Enabled = false; txtOutput.Lines = null; WebSpider spider = new WebSpider(txtUri.Text, txtBaseUri.Text, (int)spnProcessUriMax.Value); spider.webPageProcessor_.contentHandler_ += new WebPageContentDelegate(HandleContent); spider.Execute(); statusBar.Text = "Finished Processing"; ICollection webPageStateList = spider.webPages_.Values; ArrayList failedPageList = new ArrayList(); int pagesNotProcessed = 0; foreach (WebPageState webPageState in webPageStateList) { if (!webPageState.processStarted_) { pagesNotProcessed++; } else if (!webPageState.processSuccessfull_) { failedPageList.Add(webPageState); } } string[] lines = new string[failedPageList.Count * 3]; int index = 0; foreach (WebPageState webPageState in failedPageList) { lines[index++] = "Uri : " + webPageState.uri_.AbsoluteUri; lines[index++] = "Description: " + webPageState.statusDescription_; } txtOutput.Lines = lines; btnStartStop.Enabled = true; }
private void btnStartStop_Click(object sender, System.EventArgs e) { statusBar.Text = "Processed Uri: " + txtUri.Text; btnStartStop.Enabled = false; txtOutput.Lines = null; WebSpider spider = new WebSpider(txtUri.Text, txtBaseUri.Text, (int)spnProcessUriMax.Value); spider.WebPageProcessor.ContentHandler += new WebPageContentDelegate(HandleContent); spider.Execute( ); statusBar.Text = "Finished Processing"; ICollection pages = spider.WebPages.Values; ArrayList pagesFail = new ArrayList( ); int pagesNotProcessed = 0; foreach (WebPageState page in pages) { if (!page.ProcessStarted) { pagesNotProcessed++; } else if (!page.ProcessSuccessfull) { pagesFail.Add(page); } } string[] lines = new string[pagesFail.Count * 3]; int index = 0; foreach (WebPageState page in pagesFail) { lines[index++] = "Uri : " + page.Uri.AbsoluteUri; lines[index++] = "Description: " + page.StatusDescription; } txtOutput.Lines = lines; btnStartStop.Enabled = true; }