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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|