How to extract full url with HtmlAgilityPack - C#

后端 未结 2 2007
悲&欢浪女
悲&欢浪女 2020-12-06 02:58

Alright with the way below it is extracting only referring url like this

the extraction code :

foreach (HtmlNode link in hdDoc.DocumentNode.SelectNod         


        
2条回答
  •  执笔经年
    2020-12-06 03:23

    I can do it with checking the url whether containing http and if not add the domain value

    That's what you should do. Html Agility Pack has nothing to help you with this:

    var url = new Uri(
        new Uri(baseUrl).GetLeftPart(UriPartial.Path), 
        link.Attributes["href"].Value)
    ); 
    

提交回复
热议问题