Esempio n. 1
0
        /// <summary>
        /// 开始采集子页
        /// </summary>
        /// <returns></returns>
        public override bool Sniffer()
        {
            if (!Succeed || this.Done)
            {
                _done = true;
                return(false);
            }

            foreach (Match item in SnifferSubPageUrlMatchCollection)
            {
                UrlItem urlItem = new UrlItem();

                string url = item.Groups[this.ListPageConfiguration.SnifferSubPageUrlItem.UrlGroupIndex].Value;

                if (!string.IsNullOrEmpty(this.SnifferSubPageUrlItem.UrlFormat))
                {
                    url = string.Format(this.SnifferSubPageUrlItem.UrlFormat, url);
                }

                urlItem.Url   = FileUtil.GetAbsUrl(url, this.SubPageBaseUrl).Replace("&amp;", "&");
                urlItem.Title = item.Groups[this.ListPageConfiguration.SnifferSubPageUrlItem.TitleGroupIndex].Value;

                this.SubPageUrlResults.Add(urlItem);
            }
            _done = true;
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// 读取详细页重载
        /// </summary>
        /// <returns></returns>
        public static DetailPage GetDetailPage(string fileName, string rootPageName, int firstIndex, int pageIndex, int urlIndex)
        {
            ListPage firstPage = GetListPage(fileName, rootPageName, firstIndex, pageIndex);

            UrlItem urlItem = firstPage.SubPageUrlResults[urlIndex];

            DetailPageConfiguration detailPageConf = (DetailPageConfiguration)firstPage.ListPageConfiguration.SubPageConfiguration;
            DetailPage detailPage = new DetailPage(firstPage, detailPageConf);

            detailPage.PageIndex = detailPageConf.PageStartIndex;
            detailPage.PageName  = urlItem.Title;
            detailPage.PageUrl   = urlItem.Url;
            detailPage.Sniffer();

            return(detailPage);
        }