![](/img/trans.png)
[英]How can I get the links from a web page using WWW::Mechanize and Perl
[英]How can I extract all links from the page excluding one using Perl's WWW::Mechanize?
我试图使用WWW :: Mechanize使用find_all_links()
方法从HTML页面提取一些链接。 它支持根据以下条件进行匹配:
我如何提取除具有文本“ xyz”的链接以外的所有链接?
您可以使用'text_regex'
条件:
$mech->find_all_links(text_regex => qr/^(?!xyz$).*$/);
有关否定的前瞻性断言的更多信息,请参见perldoc perlre 。
为什么不获取所有链接,然后使用'grep'跳过不需要的链接?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.