Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

www::mechanize::cookbook(3pm) [debian man page]

WWW::Mechanize::Cookbook(3pm)				User Contributed Perl Documentation			     WWW::Mechanize::Cookbook(3pm)

NAME
WWW::Mechanize::Cookbook - Recipes for using WWW::Mechanize INTRODUCTION
First, please note that many of these are possible just using LWP::UserAgent. Since "WWW::Mechanize" is a subclass of LWP::UserAgent, whatever works on "LWP::UserAgent" should work on "WWW::Mechanize". See the lwpcook man page included with the libwww-perl distribution. BASICS
Launch the WWW::Mechanize browser use WWW::Mechanize; my $mech = WWW::Mechanize->new( autocheck => 1 ); The "autocheck => 1" tells Mechanize to die if any IO fails, so you don't have to manually check. It's easier that way. If you want to do your own error checking, leave it out. Fetch a page $mech->get( "http://search.cpan.org" ); print $mech->content; "$mech->content" contains the raw HTML from the web page. It is not parsed or handled in any way, at least through the "content" method. Fetch a page into a file Sometimes you want to dump your results directly into a file. For example, there's no reason to read a JPEG into memory if you're only going to write it out immediately. This can also help with memory issues on large files. $mech->get( "http://www.cpan.org/src/stable.tar.gz", ":content_file" => "stable.tar.gz" ); Fetch a password-protected page Generally, just call "credentials" before fetching the page. $mech->credentials( 'admin' => 'password' ); $mech->get( 'http://10.11.12.13/password.html' ); print $mech->content(); LINKS
Find all image links Find all links that point to a JPEG, GIF or PNG. my @links = $mech->find_all_links( tag => "a", url_regex => qr/.(jpe?g|gif|png)$/i ); Find all download links Find all links that have the word "download" in them. my @links = $mech->find_all_links( tag => "a", text_regex => qr/download/i ); APPLICATIONS
Check all pages on a web site Use Abe Timmerman's WWW::CheckSite http://search.cpan.org/dist/WWW-CheckSite/ <http://search.cpan.org/dist/WWW-CheckSite/> SEE ALSO
WWW::Mechanize AUTHORS
Copyright 2005-2010 Andy Lester "<andy@petdance.com>" Later contributions by Peter Scott, Mark Stosberg and others. See Acknowledgements section in WWW::Mechanize for more. perl v5.14.2 2011-08-05 WWW::Mechanize::Cookbook(3pm)

Check Out this Related Man Page

WWW::Mechanize::FormFiller::Value::Fixed(3pm)		User Contributed Perl Documentation	     WWW::Mechanize::FormFiller::Value::Fixed(3pm)

NAME
WWW::Mechanize::FormFiller::Value::Fixed - Fill a fixed value into an HTML form field SYNOPSIS
use WWW::Mechanize::FormFiller; use WWW::Mechanize::FormFiller::Value::Fixed; my $f = WWW::Mechanize::FormFiller->new(); # Create a fixed value for the HTML field "login" my $fixed = WWW::Mechanize::FormFiller::Value::Fixed->new( login => "Corion" ); $f->add_value( login => $fixed ); # Alternatively take the following shorthand, which adds the # field to the list as well : my $password = $f->add_filler( password => Fixed => "secret" ); DESCRIPTION
This class provides a way to write a fixed value into a HTML field. new NAME, VALUE Creates a new value which will correspond to the HTML field "NAME". The "VALUE" is the value to be written into the HTML field. name [NEWNAME] Gets and sets the name of the HTML field this value corresponds to. value FIELD Returns the value to put into the HTML field. EXPORT None by default. COPYRIGHT AND LICENSE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Copyright (C) 2002,2003 Max Maischein AUTHOR
Max Maischein, <corion@cpan.org> Please contact me if you find bugs or otherwise improve the module. More tests are also very welcome ! SEE ALSO
WWW::Mechanize, WWW::Mechanize::Shell, WWW::Mechanize::FormFiller, WWW::Mechanize::FormFiller::Value::Value, WWW::Mechanize::FormFiller::Value::Default, WWW::Mechanize::FormFiller::Value::Random, WWW::Mechanize::FormFiller::Value::Interactive perl v5.10.1 2009-04-24 WWW::Mechanize::FormFiller::Value::Fixed(3pm)
Man Page