How do I extract an HTML title with Perl?

前端 未结 7 1925
粉色の甜心
粉色の甜心 2021-01-27 07:55

Is there a way to extract HTML page title using Perl? I know it can be passed as a hidden variable during form submit and then retrieved in Perl that way but I was wondering if

相关标签:
7条回答
  • 2021-01-27 08:52

    If you just want to extract the page title you can use a regular expression. I believe that would be something like:

    my ($title) = $html =~ m/<title>(.+)<\/title>/si;
    

    where your HTML page is stored in the string $html. In si, the s stands for for single line mode (i.e., the dot also matches a newline) and i for ignore case.

    0 讨论(0)
提交回复
热议问题