How to get a link's title and href value separately with html agility pack?

后端 未结 3 938
长发绾君心
长发绾君心 2021-01-27 23:37

Im trying to download a page contain a table like this

Name
3条回答
  •  感情败类
    2021-01-28 00:12

        public const string UrlExtractor = @"(?: href\s*=)(?:[\s""']*)(?!#|mailto|location.|javascript|.*css|.*this\.)(?.*?)(?:[\s>""'])";
    
        public static Match GetMatchRegEx(string text)
        {
            return new Regex(UrlExtractor, RegexOptions.IgnoreCase).Match(text);
        }
    

    Here is how you can extract all Href Url. I'm using that regex in one of my projects, you can modify it to match your needs and rewrite it to match title as well. I guess it is more convenient to match them in bulk

提交回复
热议问题