Perl html::linkextor Modules (1)

Source: Internet
Author: User

1  UseLWP::Simple ;2  UseHtml::Linkextor;3 4 $html= Get ("http://www.baidu.com");5 $link= Html::linkextor->new (\&check);6 $link->parse ($html);7 8 Subcheck{9($tag,%links) =@_;Ten     Print "$tag \ n"; One     foreach $key(Keys %links){ A         Print "$key $links {$key}\n"; -     } - } the  - #$tag for tag types such as a, link, img, script, etc. - #%links is the hash type, the key is the link name, the value is the link value - #比如对于a标签, the key in links is href, and the value is the link name in the href + # link - # href-/favicon.ico + # link A # href-/content-search.xml at # link - # href-//www.baidu.com/img/baidu.svg - # link - # href-//s1.bdstatic.com - # link - # href-//t1.baidu.com in # link - # href-//t2.baidu.com to # link + # href-//t3.baidu.com - # link the # href-//t10.baidu.com * # link $ # href-//t11.baidu.comPanax Notoginseng # link - # href-//t12.baidu.com the # link + # href-//b1.bdstatic.com A # img the # src-//www.baidu.com/img/bd_logo1.png

This code prints all the label names in the page with the corresponding link address

If we're going to print all of the IMG addresses, then we might use $tag to determine what kind of tag, and then extract the data further.

Here's what you can see here: Perl html::linkextor modules (2)

Perl html::linkextor Modules (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.