コード例 #1
0
        private void AddToUrls(string content)
        {
            //分析出url
            // Create a new parser front-end (can be re-used)
            var parser = new HtmlParser();
            //Just get the DOM representation
            var document = parser.Parse(content);
            var Urls     = document.QuerySelectorAll(NextUrlSelector);

            foreach (IHtmlAnchorElement item in Urls)
            {
                string href = item.PathName;
                if (href == "#")
                {
                    href = URL;
                }
                else
                {
                    if (!href.StartsWith("http"))
                    {
                        href = URL.Substring(0, URL.LastIndexOf('/')) + href;
                    }
                }

                if (!string.IsNullOrEmpty(href))
                {
                    ShareData.Urls.Add(href);
                }
            }
            var Images = document.QuerySelectorAll(ImgSelector);

            foreach (IHtmlImageElement item in Images)
            {
                string url = item.Source;
                if (!string.IsNullOrEmpty(url))
                {
                    ShareData.AddImgUrl(url);
                }
            }
        }