How can I extract URL and link text from HTML in Perl?

后端 未结 11 1678
一生所求
一生所求 2020-11-27 17:19

I previously asked how to do this in Groovy. However, now I\'m rewriting my app in Perl because of all the CPAN libraries.

If the page contained these links:

<
11条回答
  •  醉话见心
    2020-11-27 17:40

    HTML is a structured markup language that has to be parsed to extract its meaning without errors. The module Sherm listed will parse the HTML and extract the links for you. Ad hoc regular expression-based solutions might be acceptable if you know that your inputs will always be formed the same way (don't forget attributes), but a parser is almost always the right answer for processing structured text.

提交回复
热议问题