hello
I'm trying to learn the basics of the mechanize module and i'm still very new to programming. Does anyone know of some good places to learn the very basics, say with some examples as well?
note - i found this example on http://search.cpan.org/~petdance/WWW-Mechanize-1.66/lib/WWW/Mechanize/Examples.pod
it is nice - indeed
use strict;
$|++;
use WWW::Mechanize;
use File::Basename;
my $m = WWW::Mechanize->new;
$m->get("http://www.despair.com/indem.html");
my @top_links = @{$m->links};
for my $top_link_num (0..$#top_links) {
next unless $top_links[$top_link_num][0] =~ /^http:/;
$m->follow_link( n=>$top_link_num ) or die "can't follow $top_
+link_num";
print $m->uri, "\n";
for my $image (grep m{^http://store4}, map $_->[0], @{$m->link
+s}) {
my $local = basename $image;
print " $image...", $m->mirror($image, $local)->message, "
+\n"
}
$m->back or die "can't go back";
}
this runs nice and gives a nice output!
Question: Does anybody have a even shorter example of mecha!?
i am looking for a
short few-line-examplescript for Newbies
look forward
btw: Update: we also have For WWW::Machanize, cookbook for several more examples.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.