Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

small small script using WWW::Mechanize

by madM (Beadle)
on Sep 18, 2013 at 00:46 UTC ( [id://1054555]=perlquestion: print w/replies, xml ) Need Help??

madM has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks! I´m learning how to use WWW::Mechanize for scraping the Web and i was trying to get a URL from the web page https://www.google.de/ but unfortunately without succes .. any suggeestions? and maybe someone knows some tutorial where you can learn to become an expert in WWW::Mechanize
my $url = 'https://www.google.de/'; my $m->get($url); my $link = $m->find_link(text => 'Bilder'); print "The Google Bilder search URL is: $link->url()\n";

Replies are listed 'Best First'.
Re: small small script using WWW::Mechanize
by atcroft (Abbot) on Sep 18, 2013 at 01:23 UTC

    First of all, I would caution that it may be against Google.de's Terms of Service to scrape results. Before proceeding, please verify that you are not in violation.

    That said, have you looked at the WWW::Mechanize::Cookbook and WWW::Mechanize::Examples? Also, have you looked at the data from the request (through the various dump_* methods) to be sure what you are getting back is what you expect?

    Hope that helps.

      thanks for your warning! but im not trying to scrap google results .. i use it only as example.. and thanks for WWW::Mechanize::Examples and Cookbook! :)

        i use it only as example

        There is an official url for that, http://example.com , its one of the official example hostnames :)

Re: small small script using WWW::Mechanize
by Khen1950fx (Canon) on Sep 18, 2013 at 01:17 UTC
    You almost had it:
    #!/usr/bin/perl -l use strict; use warnings; use WWW::Mechanize; my $url = 'https://www.google.de/'; my $agent = WWW::Mechanize->new; my $response = $agent->get($url); my $link = $agent->find_link( text => 'Bilder' ); print "The Google Bilder search URL is: ", Dumper ( $link->url );
      thanks a lot! :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1054555]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-26 06:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found