Beispiel #1
0
        private void DoWork(string url)
        {
            try
            {
                HtmlAnalyzer analyzer = new HtmlAnalyzer(url);
                analyzer.SetKeywords();
                var results = analyzer.findingWord();
                foreach (var item in results)
                {
                    var listViewItem = new ListViewItem(new string[] { item.Key, item.Value.ToString() });
                    lvResults.Items.Add(listViewItem);
                }

                lvResults.AutoResizeColumn(0, ColumnHeaderAutoResizeStyle.ColumnContent);
                lvResults.AutoResizeColumn(1, ColumnHeaderAutoResizeStyle.HeaderSize);
                lvResults.Show();
            }
            catch (UriFormatException ex)
            {
                Logger.Error(ex, "Bad url: ");
                MessageBox.Show(ex.Message);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #2
0
        public void ValidateKeyWords()
        {
            var url      = "http://www.mechatrobot.pl";
            var analyzer = new Header_Reader.HtmlAnalyzer(url);

            analyzer.SetKeywords();
            Assert.IsNotNull(analyzer.keyWordsArray);
        }
Beispiel #3
0
        public void EmptyKeyWords()
        {
            var url = "http://www.google.pl";

            try
            {
                var analyzer = new Header_Reader.HtmlAnalyzer(url);
                analyzer.SetKeywords();
                Assert.Fail("no exception thrown");
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex is Exception);
            }
        }