Ejemplo n.º 1
0
        /// <summary>
        /// 解析下一个链接
        /// </summary>
        /// <returns></returns>
        protected override string ParseNextUrl()
        {
            if (this.IsEmptyPage())
            {
                return(null);
            }

            var currentUrl = this.CurrentUrl;

            if (StringExtension.IsNullOrWhiteSpace(currentUrl))
            {
                return(null);
            }

            var nextpageUrl = HtmlDocumentHelper.GetValueByXPath(this.HtmlSource, @"//a[text()='下一页']/@href");

            if (StringExtension.IsNullOrWhiteSpace(nextpageUrl))
            {
                return(null);
            }

            string baseUrl;
            NameValueCollection collection;

            Url.ParseUrl(currentUrl, out baseUrl, out collection);

            var pageNo = int.Parse(collection[@"pageNo"]);

            collection["@pageNo"] = $"{pageNo + 1}";

            return(Url.CombinUrl(baseUrl, collection));
        }