virtus has asked for the wisdom of the Perl Monks concerning the following question:
I'm improving an old script that I had that downloaded some wallpapers for me. I need to know how many
pages of wallpapers one category have. Each link has the number of the page as its text, ie:
<a href="/planes-desktop-wallpapers/page/8">8</a> <a href="/planes-desktop-wallpapers/page/9">9</a> <a href="/planes-desktop-wallpapers/page/10">10</a>
So I need to capture the number ten, because then I can know for sure how many pages that category has.
I've been trying something like:
#!/usr/bin/perl -w use strict; use warnings; use WWW::Mechanize; use HTML::TreeBuilder; use List::Util qw(max); ... my $site = "http://www.hdwallpapers.in /planes-desktop- wallpapers.html"; $mech->get($site); my @links = map {$_->text} grep {$_->text =~ m/\d+/} $mech->find_all_links(); print max @links;
Problem is I'm also getting some junk in the array (not only numbers), so I get a compile error.
Can someone please shed some enlightenment here? tnx
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How can I retrieve the link with the highest number in it using Perl?
by toolic (Bishop) on Jul 10, 2013 at 01:31 UTC | |
by virtus (Initiate) on Jul 10, 2013 at 01:49 UTC | |
by toolic (Bishop) on Jul 10, 2013 at 03:31 UTC | |
by QM (Parson) on Jul 10, 2013 at 11:50 UTC | |
by virtus (Initiate) on Jul 10, 2013 at 19:56 UTC |