![](/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.