示例#1
0
        private void GetAll(UrlType type)
        {
            List <string> urls = new List <string>();

            switch (type)
            {
            case UrlType.Page:
                urls.Add(SearchRoot);
                break;

            case UrlType.Item:
                urls.AddRange(UrlManager.GetAll(UrlType.Page));
                break;

            case UrlType.Image:
                string[] tmpUrls = UrlManager.GetAll(UrlType.Item);
                tmpUrls = ClearExsitItems(tmpUrls);
                if (tmpUrls.Length == 0)
                {
                    PassOutputAndStopRunning();
                }
                urls.AddRange(tmpUrls);
                break;
            }
            foreach (string url in urls)
            {
                string   html    = HtmlDownloader.DownloadHtml(url);
                string[] newUrls = HtmlParser.Parse(html, type);
                for (int i = 0; i < newUrls.Length; i++)
                {
                    newUrls[i] = newUrls[i].Replace("amp;", "");
                }
                UrlManager.AddRange(newUrls, type);
            }
        }
示例#2
0
        public MimiSearcher(string url)
        {
            SearchRoot     = url;
            UrlManager     = new UrlManager();
            HtmlDownloader = new HtmlDownloader();
            HtmlParser     = new HtmlParser();
            HtmlOutputer   = new HtmlOutputer();

            // add root-url into url-manager
            UrlManager.Add(SearchRoot, UrlType.Page);
        }