Example #1
0
        public override IEnumerable <Uri> Links()
        {
            var links       = SelectList(Selectors.XPath("./descendant-or-self::*/@href"))?.Select(x => x.Value);
            var sourceLinks = SelectList(Selectors.XPath("./descendant-or-self::*/@src"))
                              ?.Select(x => x.Value);


            var results = new HashSet <Uri>();

            if (links != null)
            {
                foreach (var link in links)
                {
                    if (Uri.TryCreate(link, UriKind.Absolute, out var uri) && UriUtilities.IsHttpUri(uri))
                    {
                        results.Add(uri);
                    }
                }
            }

            if (sourceLinks != null)
            {
                foreach (var link in sourceLinks)
                {
                    if (Uri.TryCreate(link, UriKind.Absolute, out var uri) && UriUtilities.IsHttpUri(uri))
                    {
                        results.Add(uri);
                    }
                }
            }

            return(results);
        }