1WWW::Mechanize(3) User Contributed Perl Documentation WWW::Mechanize(3)
2
3
4
6 WWW::Mechanize - Handy web browsing in a Perl object
7
9 version 2.04
10
12 WWW::Mechanize supports performing a sequence of page fetches including
13 following links and submitting forms. Each fetched page is parsed and
14 its links and forms are extracted. A link or a form can be selected,
15 form fields can be filled and the next page can be fetched. Mech also
16 stores a history of the URLs you've visited, which can be queried and
17 revisited.
18
19 use WWW::Mechanize ();
20 my $mech = WWW::Mechanize->new();
21
22 $mech->get( $url );
23
24 $mech->follow_link( n => 3 );
25 $mech->follow_link( text_regex => qr/download this/i );
26 $mech->follow_link( url => 'http://host.com/index.html' );
27
28 $mech->submit_form(
29 form_number => 3,
30 fields => {
31 username => 'mungo',
32 password => 'lost-and-alone',
33 }
34 );
35
36 $mech->submit_form(
37 form_name => 'search',
38 fields => { query => 'pot of gold', },
39 button => 'Search Now'
40 );
41
42 # Enable strict form processing to catch typos and non-existant form fields.
43 my $strict_mech = WWW::Mechanize->new( strict_forms => 1);
44
45 $strict_mech->get( $url );
46
47 # This method call will die, saving you lots of time looking for the bug.
48 $strict_mech->submit_form(
49 form_number => 3,
50 fields => {
51 usernaem => 'mungo', # typo in field name
52 password => 'lost-and-alone',
53 extra_field => 123, # field does not exist
54 }
55 );
56
58 "WWW::Mechanize", or Mech for short, is a Perl module for stateful
59 programmatic web browsing, used for automating interaction with
60 websites.
61
62 Features include:
63
64 • All HTTP methods
65
66 • High-level hyperlink and HTML form support, without having to parse
67 HTML yourself
68
69 • SSL support
70
71 • Automatic cookies
72
73 • Custom HTTP headers
74
75 • Automatic handling of redirections
76
77 • Proxies
78
79 • HTTP authentication
80
81 Mech is well suited for use in testing web applications. If you use
82 one of the Test::*, like Test::HTML::Lint modules, you can check the
83 fetched content and use that as input to a test call.
84
85 use Test::More;
86 like( $mech->content(), qr/$expected/, "Got expected content" );
87
88 Each page fetch stores its URL in a history stack which you can
89 traverse.
90
91 $mech->back();
92
93 If you want finer control over your page fetching, you can use these
94 methods. "follow_link" and "submit_form" are just high level wrappers
95 around them.
96
97 $mech->find_link( n => $number );
98 $mech->form_number( $number );
99 $mech->form_name( $name );
100 $mech->field( $name, $value );
101 $mech->set_fields( %field_values );
102 $mech->set_visible( @criteria );
103 $mech->click( $button );
104
105 WWW::Mechanize is a proper subclass of LWP::UserAgent and you can also
106 use any of LWP::UserAgent's methods.
107
108 $mech->add_header($name => $value);
109
110 Please note that Mech does NOT support JavaScript, you need additional
111 software for that. Please check "JavaScript" in WWW::Mechanize::FAQ for
112 more.
113
115 • <https://github.com/libwww-perl/WWW-Mechanize/issues>
116
117 The queue for bugs & enhancements in WWW::Mechanize. Please note
118 that the queue at <http://rt.cpan.org> is no longer maintained.
119
120 • <https://metacpan.org/pod/WWW::Mechanize>
121
122 The CPAN documentation page for Mechanize.
123
124 • <https://metacpan.org/pod/distribution/WWW-Mechanize/lib/WWW/Mechanize/FAQ.pod>
125
126 Frequently asked questions. Make sure you read here FIRST.
127
129 new()
130 Creates and returns a new WWW::Mechanize object, hereafter referred to
131 as the "agent".
132
133 my $mech = WWW::Mechanize->new()
134
135 The constructor for WWW::Mechanize overrides two of the params to the
136 LWP::UserAgent constructor:
137
138 agent => 'WWW-Mechanize/#.##'
139 cookie_jar => {} # an empty, memory-only HTTP::Cookies object
140
141 You can override these overrides by passing params to the constructor,
142 as in:
143
144 my $mech = WWW::Mechanize->new( agent => 'wonderbot 1.01' );
145
146 If you want none of the overhead of a cookie jar, or don't want your
147 bot accepting cookies, you have to explicitly disallow it, like so:
148
149 my $mech = WWW::Mechanize->new( cookie_jar => undef );
150
151 Here are the params that WWW::Mechanize recognizes. These do not
152 include params that LWP::UserAgent recognizes.
153
154 • "autocheck => [0|1]"
155
156 Checks each request made to see if it was successful. This saves
157 you the trouble of manually checking yourself. Any errors found
158 are errors, not warnings.
159
160 The default value is ON, unless it's being subclassed, in which
161 case it is OFF. This means that standalone WWW::Mechanize
162 instances have autocheck turned on, which is protective for the
163 vast majority of Mech users who don't bother checking the return
164 value of get() and post() and can't figure why their code fails.
165 However, if WWW::Mechanize is subclassed, such as for
166 Test::WWW::Mechanize or Test::WWW::Mechanize::Catalyst, this may
167 not be an appropriate default, so it's off.
168
169 • "noproxy => [0|1]"
170
171 Turn off the automatic call to the LWP::UserAgent "env_proxy"
172 function.
173
174 This needs to be explicitly turned off if you're using
175 Crypt::SSLeay to access a https site via a proxy server. Note: you
176 still need to set your HTTPS_PROXY environment variable as
177 appropriate.
178
179 • "onwarn => \&func"
180
181 Reference to a "warn"-compatible function, such as "Carp::carp",
182 that is called when a warning needs to be shown.
183
184 If this is set to "undef", no warnings will ever be shown.
185 However, it's probably better to use the "quiet" method to control
186 that behavior.
187
188 If this value is not passed, Mech uses "Carp::carp" if Carp is
189 installed, or "CORE::warn" if not.
190
191 • "onerror => \&func"
192
193 Reference to a "die"-compatible function, such as "Carp::croak",
194 that is called when there's a fatal error.
195
196 If this is set to "undef", no errors will ever be shown.
197
198 If this value is not passed, Mech uses "Carp::croak" if Carp is
199 installed, or "CORE::die" if not.
200
201 • "quiet => [0|1]"
202
203 Don't complain on warnings. Setting "quiet => 1" is the same as
204 calling "$mech->quiet(1)". Default is off.
205
206 • "stack_depth => $value"
207
208 Sets the depth of the page stack that keeps track of all the
209 downloaded pages. Default is effectively infinite stack size. If
210 the stack is eating up your memory, then set this to a smaller
211 number, say 5 or 10. Setting this to zero means Mech will keep no
212 history.
213
214 In addition, WWW::Mechanize also allows you to globally enable strict
215 and verbose mode for form handling, which is done with HTML::Form.
216
217 • "strict_forms => [0|1]"
218
219 Globally sets the HTML::Form strict flag which causes form
220 submission to croak if any of the passed fields don't exist in the
221 form, and/or a value doesn't exist in a select element. This can
222 still be disabled in individual calls to "submit_form()".
223
224 Default is off.
225
226 • "verbose_forms => [0|1]"
227
228 Globally sets the HTML::Form verbose flag which causes form
229 submission to warn about any bad HTML form constructs found. This
230 cannot be disabled later.
231
232 Default is off.
233
234 • "marked_sections => [0|1]"
235
236 Globally sets the HTML::Parser marked sections flag which causes
237 HTML "CDATA[[" sections to be honoured. This cannot be disabled
238 later.
239
240 Default is on.
241
242 To support forms, WWW::Mechanize's constructor pushes POST on to the
243 agent's "requests_redirectable" list (see also LWP::UserAgent.)
244
245 $mech->agent_alias( $alias )
246 Sets the user agent string to the expanded version from a table of
247 actual user strings. $alias can be one of the following:
248
249 • Windows IE 6
250
251 • Windows Mozilla
252
253 • Mac Safari
254
255 • Mac Mozilla
256
257 • Linux Mozilla
258
259 • Linux Konqueror
260
261 then it will be replaced with a more interesting one. For instance,
262
263 $mech->agent_alias( 'Windows IE 6' );
264
265 sets your User-Agent to
266
267 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
268
269 The list of valid aliases can be returned from "known_agent_aliases()".
270 The current list is:
271
272 • Windows IE 6
273
274 • Windows Mozilla
275
276 • Mac Safari
277
278 • Mac Mozilla
279
280 • Linux Mozilla
281
282 • Linux Konqueror
283
284 known_agent_aliases()
285 Returns a list of all the agent aliases that Mech knows about.
286
288 $mech->get( $uri )
289 Given a URL/URI, fetches it. Returns an HTTP::Response object. $uri
290 can be a well-formed URL string, a URI object, or a
291 WWW::Mechanize::Link object.
292
293 The results are stored internally in the agent object, but you don't
294 know that. Just use the accessors listed below. Poking at the
295 internals is deprecated and subject to change in the future.
296
297 "get()" is a well-behaved overloaded version of the method in
298 LWP::UserAgent. This lets you do things like
299
300 $mech->get( $uri, ':content_file' => $filename );
301
302 and you can rest assured that the params will get filtered down
303 appropriately. See "get" in LWP::UserAgent for more details.
304
305 NOTE: Because ":content_file" causes the page contents to be stored in
306 a file instead of the response object, some Mech functions that expect
307 it to be there won't work as expected. Use with caution.
308
309 $mech->post( $uri, content => $content )
310 POSTs $content to $uri. Returns an HTTP::Response object. $uri can be
311 a well-formed URI string, a URI object, or a WWW::Mechanize::Link
312 object.
313
314 $mech->put( $uri, content => $content )
315 PUTs $content to $uri. Returns an HTTP::Response object. $uri can be
316 a well-formed URI string, a URI object, or a WWW::Mechanize::Link
317 object.
318
319 my $res = $mech->head( $uri );
320 my $res = $mech->head( $uri , $field_name => $value, ... );
321
322 $mech->head ($uri )
323 Performs a HEAD request to $uri. Returns an HTTP::Response object.
324 $uri can be a well-formed URI string, a URI object, or a
325 WWW::Mechanize::Link object.
326
327 $mech->reload()
328 Acts like the reload button in a browser: repeats the current request.
329 The history (as per the back() method) is not altered.
330
331 Returns the HTTP::Response object from the reload, or "undef" if
332 there's no current request.
333
334 $mech->back()
335 The equivalent of hitting the "back" button in a browser. Returns to
336 the previous page. Won't go back past the first page. (Really, what
337 would it do if it could?)
338
339 Returns true if it could go back, or false if not.
340
341 $mech->clear_history()
342 This deletes all the history entries and returns true.
343
344 $mech->history_count()
345 This returns the number of items in the browser history. This number
346 does include the most recently made request.
347
348 $mech->history($n)
349 This returns the nth item in history. The 0th item is the most recent
350 request and response, which would be acted on by methods like
351 "find_link()". The 1st item is the state you'd return to if you called
352 "back()".
353
354 The maximum useful value for $n is "$mech->history_count - 1".
355 Requests beyond that bound will return "undef".
356
357 History items are returned as hash references, in the form:
358
359 { req => $http_request, res => $http_response }
360
362 $mech->success()
363 Returns a boolean telling whether the last request was successful. If
364 there hasn't been an operation yet, returns false.
365
366 This is a convenience function that wraps "$mech->res->is_success".
367
368 $mech->uri()
369 Returns the current URI as a URI object. This object stringifies to the
370 URI itself.
371
372 $mech->response() / $mech->res()
373 Return the current response as an HTTP::Response object.
374
375 Synonym for "$mech->response()"
376
377 $mech->status()
378 Returns the HTTP status code of the response. This is a 3-digit number
379 like 200 for OK, 404 for not found, and so on.
380
381 $mech->ct() / $mech->content_type()
382 Returns the content type of the response.
383
384 $mech->base()
385 Returns the base URI for the current response
386
387 $mech->forms()
388 When called in a list context, returns a list of the forms found in the
389 last fetched page. In a scalar context, returns a reference to an array
390 with those forms. The forms returned are all HTML::Form objects.
391
392 $mech->current_form()
393 Returns the current form as an HTML::Form object.
394
395 $mech->links()
396 When called in a list context, returns a list of the links found in the
397 last fetched page. In a scalar context it returns a reference to an
398 array with those links. Each link is a WWW::Mechanize::Link object.
399
400 $mech->is_html()
401 Returns true/false on whether our content is HTML, according to the
402 HTTP headers.
403
404 $mech->title()
405 Returns the contents of the "<TITLE>" tag, as parsed by
406 HTML::HeadParser. Returns undef if the content is not HTML.
407
408 $mech->redirects()
409 Convenience method to get the redirects from the most recent
410 HTTP::Response.
411
412 Note that you can also use is_redirect to see if the most recent
413 response was a redirect like this.
414
415 $mech->get($url);
416 do_stuff() if $mech->res->is_redirect;
417
419 $mech->content(...)
420 Returns the content that the mech uses internally for the last page
421 fetched. Ordinarily this is the same as
422 "$mech->response()->decoded_content()", but this may differ for HTML
423 documents if update_html is overloaded (in which case the value passed
424 to the base-class implementation of same will be returned), and/or
425 extra named arguments are passed to content():
426
427 $mech->content( format => 'text' )
428 Returns a text-only version of the page, with all HTML markup
429 stripped. This feature requires HTML::TreeBuilder version 5 or higher
430 to be installed, or a fatal error will be thrown. This works only if
431 the contents are HTML.
432
433 $mech->content( base_href => [$base_href|undef] )
434 Returns the HTML document, modified to contain a "<base
435 href="$base_href">" mark-up in the header. $base_href is
436 "$mech->base()" if not specified. This is handy to pass the HTML to
437 e.g. HTML::Display. This works only if the contents are HTML.
438
439 $mech->content( raw => 1 )
440 Returns "$self->response()->content()", i.e. the raw contents from
441 the response.
442
443 $mech->content( decoded_by_headers => 1 )
444 Returns the content after applying all "Content-Encoding" headers but
445 with not additional mangling.
446
447 $mech->content( charset => $charset )
448 Returns "$self->response()->decoded_content(charset => $charset)"
449 (see HTTP::Response for details).
450
451 To preserve backwards compatibility, additional parameters will be
452 ignored unless none of "raw | decoded_by_headers | charset" is
453 specified and the text is HTML, in which case an error will be
454 triggered.
455
456 A fresh instance of WWW::Mechanize will return "undef" when
457 "$mech->content()" is called, because no content is present before a
458 request has been made.
459
460 $mech->text()
461 Returns the text of the current HTML content. If the content isn't
462 HTML, $mech will die.
463
464 The text is extracted by parsing the content, and then the extracted
465 text is cached, so don't worry about performance of calling this
466 repeatedly.
467
469 $mech->links()
470 Lists all the links on the current page. Each link is a
471 WWW::Mechanize::Link object. In list context, returns a list of all
472 links. In scalar context, returns an array reference of all links.
473
474 $mech->follow_link(...)
475 Follows a specified link on the page. You specify the match to be
476 found using the same params that "find_link()" uses.
477
478 Here some examples:
479
480 • 3rd link called "download"
481
482 $mech->follow_link( text => 'download', n => 3 );
483
484 • first link where the URL has "download" in it, regardless of case:
485
486 $mech->follow_link( url_regex => qr/download/i );
487
488 or
489
490 $mech->follow_link( url_regex => qr/(?i:download)/ );
491
492 • 3rd link on the page
493
494 $mech->follow_link( n => 3 );
495
496 • the link with the url
497
498 $mech->follow_link( url => '/other/page' );
499
500 or
501
502 $mech->follow_link( url => 'http://example.com/page' );
503
504 Returns the result of the "GET" method (an HTTP::Response object) if a
505 link was found.
506
507 If the page has no links, or the specified link couldn't be found,
508 returns "undef". If "autocheck" is enabled an exception will be thrown
509 instead.
510
511 $mech->find_link( ... )
512 Finds a link in the currently fetched page. It returns a
513 WWW::Mechanize::Link object which describes the link. (You'll probably
514 be most interested in the "url()" property.) If it fails to find a
515 link it returns undef.
516
517 You can take the URL part and pass it to the "get()" method. If that's
518 your plan, you might as well use the "follow_link()" method directly,
519 since it does the "get()" for you automatically.
520
521 Note that "<FRAME SRC="...">" tags are parsed out of the HTML and
522 treated as links so this method works with them.
523
524 You can select which link to find by passing in one or more of these
525 key/value pairs:
526
527 • "text => 'string'," and "text_regex => qr/regex/,"
528
529 "text" matches the text of the link against string, which must be
530 an exact match. To select a link with text that is exactly
531 "download", use
532
533 $mech->find_link( text => 'download' );
534
535 "text_regex" matches the text of the link against regex. To select
536 a link with text that has "download" anywhere in it, regardless of
537 case, use
538
539 $mech->find_link( text_regex => qr/download/i );
540
541 Note that the text extracted from the page's links are trimmed.
542 For example, "<a> foo </a>" is stored as 'foo', and searching for
543 leading or trailing spaces will fail.
544
545 • "url => 'string'," and "url_regex => qr/regex/,"
546
547 Matches the URL of the link against string or regex, as
548 appropriate. The URL may be a relative URL, like foo/bar.html,
549 depending on how it's coded on the page.
550
551 • "url_abs => string" and "url_abs_regex => regex"
552
553 Matches the absolute URL of the link against string or regex, as
554 appropriate. The URL will be an absolute URL, even if it's
555 relative in the page.
556
557 • "name => string" and "name_regex => regex"
558
559 Matches the name of the link against string or regex, as
560 appropriate.
561
562 • "rel => string" and "rel_regex => regex"
563
564 Matches the rel of the link against string or regex, as
565 appropriate. This can be used to find stylesheets, favicons, or
566 links the author of the page does not want bots to follow.
567
568 • "id => string" and "id_regex => regex"
569
570 Matches the attribute 'id' of the link against string or regex, as
571 appropriate.
572
573 • "class => string" and "class_regex => regex"
574
575 Matches the attribute 'class' of the link against string or regex,
576 as appropriate.
577
578 • "tag => string" and "tag_regex => regex"
579
580 Matches the tag that the link came from against string or regex, as
581 appropriate. The "tag_regex" is probably most useful to check for
582 more than one tag, as in:
583
584 $mech->find_link( tag_regex => qr/^(a|frame)$/ );
585
586 The tags and attributes looked at are defined below.
587
588 If "n" is not specified, it defaults to 1. Therefore, if you don't
589 specify any params, this method defaults to finding the first link on
590 the page.
591
592 Note that you can specify multiple text or URL parameters, which will
593 be ANDed together. For example, to find the first link with text of
594 "News" and with "cnn.com" in the URL, use:
595
596 $mech->find_link( text => 'News', url_regex => qr/cnn\.com/ );
597
598 The return value is a reference to an array containing a
599 WWW::Mechanize::Link object for every link in "$self->content".
600
601 The links come from the following:
602
603 "<a href=...>"
604 "<area href=...>"
605 "<frame src=...>"
606 "<iframe src=...>"
607 "<link href=...>"
608 "<meta content=...>"
609
610 $mech->find_all_links( ... )
611 Returns all the links on the current page that match the criteria. The
612 method for specifying link criteria is the same as in "find_link()".
613 Each of the links returned is a WWW::Mechanize::Link object.
614
615 In list context, "find_all_links()" returns a list of the links.
616 Otherwise, it returns a reference to the list of links.
617
618 "find_all_links()" with no parameters returns all links in the page.
619
620 $mech->find_all_inputs( ... criteria ... )
621 find_all_inputs() returns an array of all the input controls in the
622 current form whose properties match all of the regexes passed in. The
623 controls returned are all descended from HTML::Form::Input. See
624 "INPUTS" in HTML::Form for details.
625
626 If no criteria are passed, all inputs will be returned.
627
628 If there is no current page, there is no form on the current page, or
629 there are no submit controls in the current form then the return will
630 be an empty array.
631
632 You may use a regex or a literal string:
633
634 # get all textarea controls whose names begin with "customer"
635 my @customer_text_inputs = $mech->find_all_inputs(
636 type => 'textarea',
637 name_regex => qr/^customer/,
638 );
639
640 # get all text or textarea controls called "customer"
641 my @customer_text_inputs = $mech->find_all_inputs(
642 type_regex => qr/^(text|textarea)$/,
643 name => 'customer',
644 );
645
646 $mech->find_all_submits( ... criteria ... )
647 "find_all_submits()" does the same thing as "find_all_inputs()" except
648 that it only returns controls that are submit controls, ignoring other
649 types of input controls like text and checkboxes.
650
652 $mech->images
653 Lists all the images on the current page. Each image is a
654 WWW::Mechanize::Image object. In list context, returns a list of all
655 images. In scalar context, returns an array reference of all images.
656
657 $mech->find_image()
658 Finds an image in the current page. It returns a WWW::Mechanize::Image
659 object which describes the image. If it fails to find an image it
660 returns undef.
661
662 You can select which image to find by passing in one or more of these
663 key/value pairs:
664
665 • "alt => 'string'" and "alt_regex => qr/regex/"
666
667 "alt" matches the ALT attribute of the image against string, which
668 must be an exact match. To select a image with an ALT tag that is
669 exactly "download", use
670
671 $mech->find_image( alt => 'download' );
672
673 "alt_regex" matches the ALT attribute of the image against a
674 regular expression. To select an image with an ALT attribute that
675 has "download" anywhere in it, regardless of case, use
676
677 $mech->find_image( alt_regex => qr/download/i );
678
679 • "url => 'string'" and "url_regex => qr/regex/"
680
681 Matches the URL of the image against string or regex, as
682 appropriate. The URL may be a relative URL, like foo/bar.html,
683 depending on how it's coded on the page.
684
685 • "url_abs => string" and "url_abs_regex => regex"
686
687 Matches the absolute URL of the image against string or regex, as
688 appropriate. The URL will be an absolute URL, even if it's
689 relative in the page.
690
691 • "tag => string" and "tag_regex => regex"
692
693 Matches the tag that the image came from against string or regex,
694 as appropriate. The "tag_regex" is probably most useful to check
695 for more than one tag, as in:
696
697 $mech->find_image( tag_regex => qr/^(img|input)$/ );
698
699 The tags supported are "<img>" and "<input>".
700
701 • "id => string" and "id_regex => regex"
702
703 "id" matches the id attribute of the image against string, which
704 must be an exact match. To select an image with the exact id
705 "download-image", use
706
707 $mech->find_image( id => 'download-image' );
708
709 "id_regex" matches the id attribute of the image against a regular
710 expression. To select the first image with an id that contains
711 "download" anywhere in it, use
712
713 $mech->find_image( id_regex => qr/download/ );
714
715 • "classs => string" and "class_regex => regex"
716
717 "class" matches the class attribute of the image against string,
718 which must be an exact match. To select an image with the exact
719 class "img-fuid", use
720
721 $mech->find_image( class => 'img-fluid' );
722
723 To select an image with the class attribute "rounded float-left",
724 use
725
726 $mech->find_image( class => 'rounded float-left' );
727
728 Note that the classes have to be matched as a complete string, in
729 the exact order they appear in the website's source code.
730
731 "class_regex" matches the class attribute of the image against a
732 regular expression. Use this if you want a partial class name, or
733 if an image has several classes, but you only care about one.
734
735 To select the first image with the class "rounded", where there are
736 multiple images that might also have either class "float-left" or
737 "float-right", use
738
739 $mech->find_image( class_regex => qr/\brounded\b/ );
740
741 Selecting an image with multiple classes where you do not care
742 about the order they appear in the website's source code is not
743 currently supported.
744
745 If "n" is not specified, it defaults to 1. Therefore, if you don't
746 specify any params, this method defaults to finding the first image on
747 the page.
748
749 Note that you can specify multiple ALT or URL parameters, which will be
750 ANDed together. For example, to find the first image with ALT text of
751 "News" and with "cnn.com" in the URL, use:
752
753 $mech->find_image( image => 'News', url_regex => qr/cnn\.com/ );
754
755 The return value is a reference to an array containing a
756 WWW::Mechanize::Image object for every image in "$self->content".
757
758 $mech->find_all_images( ... )
759 Returns all the images on the current page that match the criteria.
760 The method for specifying image criteria is the same as in
761 "find_image()". Each of the images returned is a WWW::Mechanize::Image
762 object.
763
764 In list context, "find_all_images()" returns a list of the images.
765 Otherwise, it returns a reference to the list of images.
766
767 "find_all_images()" with no parameters returns all images in the page.
768
770 These methods let you work with the forms on a page. The idea is to
771 choose a form that you'll later work with using the field methods
772 below.
773
774 $mech->forms
775 Lists all the forms on the current page. Each form is an HTML::Form
776 object. In list context, returns a list of all forms. In scalar
777 context, returns an array reference of all forms.
778
779 $mech->form_number($number)
780 Selects the numberth form on the page as the target for subsequent
781 calls to "field()" and "click()". Also returns the form that was
782 selected.
783
784 If it is found, the form is returned as an HTML::Form object and set
785 internally for later use with Mech's form methods such as "field()" and
786 "click()". When called in a list context, the number of the found form
787 is also returned as a second value.
788
789 Emits a warning and returns undef if no form is found.
790
791 The first form is number 1, not zero.
792
793 $mech->form_name( $name )
794 Selects a form by name. If there is more than one form on the page
795 with that name, then the first one is used, and a warning is generated.
796
797 If it is found, the form is returned as an HTML::Form object and set
798 internally for later use with Mech's form methods such as "field()" and
799 "click()".
800
801 Returns undef if no form is found.
802
803 $mech->form_id( $id )
804 Selects a form by ID. If there is more than one form on the page with
805 that ID, then the first one is used, and a warning is generated.
806
807 If it is found, the form is returned as an HTML::Form object and set
808 internally for later use with Mech's form methods such as "field()" and
809 "click()".
810
811 If no form is found it returns "undef". This will also trigger a
812 warning, unless "quiet" is enabled.
813
814 $mech->all_forms_with_fields( @fields )
815 Selects a form by passing in a list of field names it must contain.
816 All matching forms (perhaps none) are returned as a list of HTML::Form
817 objects.
818
819 $mech->form_with_fields( @fields )
820 Selects a form by passing in a list of field names it must contain. If
821 there is more than one form on the page with that matches, then the
822 first one is used, and a warning is generated.
823
824 If it is found, the form is returned as an HTML::Form object and set
825 internally for later used with Mech's form methods such as "field()"
826 and "click()".
827
828 Returns undef and emits a warning if no form is found.
829
830 Note that this functionality requires libwww-perl 5.69 or higher.
831
832 $mech->all_forms_with( $attr1 => $value1, $attr2 => $value2, ... )
833 Searches for forms with arbitrary attribute/value pairs within the
834 <form> tag. (Currently does not work for attribute "action" due to
835 implementation details of HTML::Form.) When given more than one pair,
836 all criteria must match. Using "undef" as value means that the
837 attribute in question must not be present.
838
839 All matching forms (perhaps none) are returned as a list of HTML::Form
840 objects.
841
842 $mech->form_with( $attr1 => $value1, $attr2 => $value2, ... )
843 Searches for forms with arbitrary attribute/value pairs within the
844 <form> tag. (Currently does not work for attribute "action" due to
845 implementation details of HTML::Form.) When given more than one pair,
846 all criteria must match. Using "undef" as value means that the
847 attribute in question must not be present.
848
849 If it is found, the form is returned as an HTML::Form object and set
850 internally for later used with Mech's form methods such as "field()"
851 and "click()".
852
853 Returns undef if no form is found.
854
856 These methods allow you to set the values of fields in a given form.
857
858 $mech->field( $name, $value, $number )
859 $mech->field( $name, \@values, $number )
860 Given the name of a field, set its value to the value specified. This
861 applies to the current form (as set by the "form_name()" or
862 "form_number()" method or defaulting to the first form on the page).
863
864 The optional $number parameter is used to distinguish between two
865 fields with the same name. The fields are numbered from 1.
866
867 $mech->select($name, $value)
868 $mech->select($name, \@values)
869 Given the name of a "select" field, set its value to the value
870 specified. If the field is not "<select multiple>" and the $value is
871 an array, only the first value will be set. [Note: the documentation
872 previously claimed that only the last value would be set, but this was
873 incorrect.] Passing $value as a hash with an "n" key selects an item
874 by number (e.g. "{n => 3}" or "{n => [2,4]}"). The numbering starts
875 at 1. This applies to the current form.
876
877 If you have a field with "<select multiple>" and you pass a single
878 $value, then $value will be added to the list of fields selected,
879 without clearing the others. However, if you pass an array reference,
880 then all previously selected values will be cleared.
881
882 Returns true on successfully setting the value. On failure, returns
883 false and calls "$self->warn()" with an error message.
884
885 $mech->set_fields( $name => $value ... )
886 This method sets multiple fields of the current form. It takes a list
887 of field name and value pairs. If there is more than one field with the
888 same name, the first one found is set. If you want to select which of
889 the duplicate field to set, use a value which is an anonymous array
890 which has the field value and its number as the 2 elements.
891
892 # set the second foo field
893 $mech->set_fields( $name => [ 'foo', 2 ] );
894
895 The fields are numbered from 1.
896
897 This applies to the current form.
898
899 $mech->set_visible( @criteria )
900 This method sets fields of the current form without having to know
901 their names. So if you have a login screen that wants a username and
902 password, you do not have to fetch the form and inspect the source (or
903 use the mech-dump utility, installed with WWW::Mechanize) to see what
904 the field names are; you can just say
905
906 $mech->set_visible( $username, $password );
907
908 and the first and second fields will be set accordingly. The method is
909 called set_visible because it acts only on visible fields; hidden form
910 inputs are not considered. The order of the fields is the order in
911 which they appear in the HTML source which is nearly always the order
912 anyone viewing the page would think they are in, but some creative work
913 with tables could change that; caveat user.
914
915 Each element in @criteria is either a field value or a field specifier.
916 A field value is a scalar. A field specifier allows you to specify the
917 type of input field you want to set and is denoted with an arrayref
918 containing two elements. So you could specify the first radio button
919 with
920
921 $mech->set_visible( [ radio => 'KCRW' ] );
922
923 Field values and specifiers can be intermixed, hence
924
925 $mech->set_visible( 'fred', 'secret', [ option => 'Checking' ] );
926
927 would set the first two fields to "fred" and "secret", and the next
928 "OPTION" menu field to "Checking".
929
930 The possible field specifier types are: "text", "password", "hidden",
931 "textarea", "file", "image", "submit", "radio", "checkbox" and
932 "option".
933
934 "set_visible" returns the number of values set.
935
936 $mech->tick( $name, $value [, $set] )
937 "Ticks" the first checkbox that has both the name and value associated
938 with it on the current form. Dies if there is no named check box for
939 that value. Passing in a false value as the third optional argument
940 will cause the checkbox to be unticked.
941
942 $mech->untick($name, $value)
943 Causes the checkbox to be unticked. Shorthand for
944 "tick($name,$value,undef)"
945
946 $mech->value( $name [, $number] )
947 Given the name of a field, return its value. This applies to the
948 current form.
949
950 The optional $number parameter is used to distinguish between two
951 fields with the same name. The fields are numbered from 1.
952
953 If the field is of type file (file upload field), the value is always
954 cleared to prevent remote sites from downloading your local files. To
955 upload a file, specify its file name explicitly.
956
957 $mech->click( $button [, $x, $y] )
958 Has the effect of clicking a button on the current form. The first
959 argument is the name of the button to be clicked. The second and third
960 arguments (optional) allow you to specify the (x,y) coordinates of the
961 click.
962
963 If there is only one button on the form, "$mech->click()" with no
964 arguments simply clicks that one button.
965
966 Returns an HTTP::Response object.
967
968 $mech->click_button( ... )
969 Has the effect of clicking a button on the current form by specifying
970 its attributes. The arguments are a list of key/value pairs. Only one
971 of name, id, number, input or value must be specified in the keys.
972
973 Dies if no button is found.
974
975 • "name => name"
976
977 Clicks the button named name in the current form.
978
979 • "id => id"
980
981 Clicks the button with the id id in the current form.
982
983 • "number => n"
984
985 Clicks the nth button with type submit in the current form.
986 Numbering starts at 1.
987
988 • "value => value"
989
990 Clicks the button with the value value in the current form.
991
992 • "input => $inputobject"
993
994 Clicks on the button referenced by $inputobject, an instance of
995 HTML::Form::SubmitInput obtained e.g. from
996
997 $mech->current_form()->find_input( undef, 'submit' )
998
999 $inputobject must belong to the current form.
1000
1001 • "x => x"
1002
1003 • "y => y"
1004
1005 These arguments (optional) allow you to specify the (x,y)
1006 coordinates of the click.
1007
1008 $mech->submit()
1009 Submits the current form, without specifying a button to click.
1010 Actually, no button is clicked at all.
1011
1012 Returns an HTTP::Response object.
1013
1014 This used to be a synonym for "$mech->click( 'submit' )", but is no
1015 longer so.
1016
1017 $mech->submit_form( ... )
1018 This method lets you select a form from the previously fetched page,
1019 fill in its fields, and submit it. It combines the
1020 "form_number"/"form_name", "set_fields" and "click" methods into one
1021 higher level call. Its arguments are a list of key/value pairs, all of
1022 which are optional.
1023
1024 • "fields => \%fields"
1025
1026 Specifies the fields to be filled in the current form.
1027
1028 • "with_fields => \%fields"
1029
1030 Probably all you need for the common case. It combines a smart form
1031 selector and data setting in one operation. It selects the first
1032 form that contains all fields mentioned in "\%fields". This is
1033 nice because you don't need to know the name or number of the form
1034 to do this.
1035
1036 (calls "form_with_fields()" and
1037 "set_fields()").
1038
1039 If you choose "with_fields", the "fields" option will be ignored.
1040 The "form_number", "form_name" and "form_id" options will still be
1041 used. An exception will be thrown unless exactly one form matches
1042 all of the provided criteria.
1043
1044 • "form_number => n"
1045
1046 Selects the nth form (calls "form_number()". If this param is not
1047 specified, the currently-selected form is used.
1048
1049 • "form_name => name"
1050
1051 Selects the form named name (calls "form_name()")
1052
1053 • "form_id => ID"
1054
1055 Selects the form with ID ID (calls "form_id()")
1056
1057 • "button => button"
1058
1059 Clicks on button button (calls "click()")
1060
1061 • "x => x, y => y"
1062
1063 Sets the x or y values for "click()"
1064
1065 • "strict_forms => bool"
1066
1067 Sets the HTML::Form strict flag which causes form submission to
1068 croak if any of the passed fields don't exist on the page, and/or a
1069 value doesn't exist in a select element. By default HTML::Form
1070 sets this value to false.
1071
1072 This behavior can also be turned on globally by passing
1073 "strict_forms => 1" to "WWW::Mechanize->new". If you do that, you
1074 can still disable it for individual calls by passing "strict_forms
1075 => 0" here.
1076
1077 If no form is selected, the first form found is used.
1078
1079 If button is not passed, then the "submit()" method is used instead.
1080
1081 If you want to submit a file and get its content from a scalar rather
1082 than a file in the filesystem, you can use:
1083
1084 $mech->submit_form(with_fields => { logfile => [ [ undef, 'whatever', Content => $content ], 1 ] } );
1085
1086 Returns an HTTP::Response object.
1087
1089 $mech->add_header( name => $value [, name => $value... ] )
1090 Sets HTTP headers for the agent to add or remove from the HTTP request.
1091
1092 $mech->add_header( Encoding => 'text/klingon' );
1093
1094 If a value is "undef", then that header will be removed from any future
1095 requests. For example, to never send a Referer header:
1096
1097 $mech->add_header( Referer => undef );
1098
1099 If you want to delete a header, use "delete_header".
1100
1101 Returns the number of name/value pairs added.
1102
1103 NOTE: This method was very different in WWW::Mechanize before 1.00.
1104 Back then, the headers were stored in a package hash, not as a member
1105 of the object instance. Calling "add_header()" would modify the
1106 headers for every WWW::Mechanize object, even after your object no
1107 longer existed.
1108
1109 $mech->delete_header( name [, name ... ] )
1110 Removes HTTP headers from the agent's list of special headers. For
1111 instance, you might need to do something like:
1112
1113 # Don't send a Referer for this URL
1114 $mech->add_header( Referer => undef );
1115
1116 # Get the URL
1117 $mech->get( $url );
1118
1119 # Back to the default behavior
1120 $mech->delete_header( 'Referer' );
1121
1122 $mech->quiet(true/false)
1123 Allows you to suppress warnings to the screen.
1124
1125 $mech->quiet(0); # turns on warnings (the default)
1126 $mech->quiet(1); # turns off warnings
1127 $mech->quiet(); # returns the current quietness status
1128
1129 $mech->stack_depth( $max_depth )
1130 Get or set the page stack depth. Use this if you're doing a lot of page
1131 scraping and running out of memory.
1132
1133 A value of 0 means "no history at all." By default, the max stack
1134 depth is humongously large, effectively keeping all history.
1135
1136 $mech->save_content( $filename, %opts )
1137 Dumps the contents of "$mech->content" into $filename. $filename will
1138 be overwritten. Dies if there are any errors.
1139
1140 If the content type does not begin with "text/", then the content is
1141 saved in binary mode (i.e. "binmode()" is set on the output
1142 filehandle).
1143
1144 Additional arguments can be passed as key/value pairs:
1145
1146 $mech->save_content( $filename, binary => 1 )
1147 Filehandle is set with "binmode" to ":raw" and contents are taken
1148 calling "$self->content(decoded_by_headers => 1)". Same as calling:
1149
1150 $mech->save_content( $filename, binmode => ':raw',
1151 decoded_by_headers => 1 );
1152
1153 This should be the safest way to save contents verbatim.
1154
1155 $mech->save_content( $filename, binmode => $binmode )
1156 Filehandle is set to binary mode. If $binmode begins with ':', it
1157 is passed as a parameter to "binmode":
1158
1159 binmode $fh, $binmode;
1160
1161 otherwise the filehandle is set to binary mode if $binmode is true:
1162
1163 binmode $fh;
1164
1165 all other arguments
1166 are passed as-is to "$mech->content(%opts)". In particular,
1167 "decoded_by_headers" might come handy if you want to revert the
1168 effect of line compression performed by the web server but without
1169 further interpreting the contents (e.g. decoding it according to
1170 the charset).
1171
1172 $mech->dump_headers( [$fh] )
1173 Prints a dump of the HTTP response headers for the most recent
1174 response. If $fh is not specified or is undef, it dumps to STDOUT.
1175
1176 Unlike the rest of the dump_* methods, $fh can be a scalar. It will be
1177 used as a file name.
1178
1179 $mech->dump_links( [[$fh], $absolute] )
1180 Prints a dump of the links on the current page to $fh. If $fh is not
1181 specified or is undef, it dumps to STDOUT.
1182
1183 If $absolute is true, links displayed are absolute, not relative.
1184
1185 $mech->dump_images( [[$fh], $absolute] )
1186 Prints a dump of the images on the current page to $fh. If $fh is not
1187 specified or is undef, it dumps to STDOUT.
1188
1189 If $absolute is true, links displayed are absolute, not relative.
1190
1191 The output will include empty lines for images that have no "src"
1192 attribute and therefore no "<-"url>>.
1193
1194 $mech->dump_forms( [$fh] )
1195 Prints a dump of the forms on the current page to $fh. If $fh is not
1196 specified or is undef, it dumps to STDOUT. Running the following:
1197
1198 my $mech = WWW::Mechanize->new();
1199 $mech->get("https://www.google.com/");
1200 $mech->dump_forms;
1201
1202 will print:
1203
1204 GET https://www.google.com/search [f]
1205 ie=ISO-8859-1 (hidden readonly)
1206 hl=en (hidden readonly)
1207 source=hp (hidden readonly)
1208 biw= (hidden readonly)
1209 bih= (hidden readonly)
1210 q= (text)
1211 btnG=Google Search (submit)
1212 btnI=I'm Feeling Lucky (submit)
1213 gbv=1 (hidden readonly)
1214
1215 $mech->dump_text( [$fh] )
1216 Prints a dump of the text on the current page to $fh. If $fh is not
1217 specified or is undef, it dumps to STDOUT.
1218
1220 $mech->clone()
1221 Clone the mech object. The clone will be using the same cookie jar as
1222 the original mech.
1223
1224 $mech->redirect_ok()
1225 An overloaded version of "redirect_ok()" in LWP::UserAgent. This
1226 method is used to determine whether a redirection in the request should
1227 be followed.
1228
1229 Note that WWW::Mechanize's constructor pushes POST on to the agent's
1230 "requests_redirectable" list.
1231
1232 $mech->request( $request [, $arg [, $size]])
1233 Overloaded version of "request()" in LWP::UserAgent. Performs the
1234 actual request. Normally, if you're using WWW::Mechanize, it's because
1235 you don't want to deal with this level of stuff anyway.
1236
1237 Note that $request will be modified.
1238
1239 Returns an HTTP::Response object.
1240
1241 $mech->update_html( $html )
1242 Allows you to replace the HTML that the mech has found. Updates the
1243 forms and links parse-trees that the mech uses internally.
1244
1245 Say you have a page that you know has malformed output, and you want to
1246 update it so the links come out correctly:
1247
1248 my $html = $mech->content;
1249 $html =~ s[</option>.{0,3}</td>][</option></select></td>]isg;
1250 $mech->update_html( $html );
1251
1252 This method is also used internally by the mech itself to update its
1253 own HTML content when loading a page. This means that if you would like
1254 to systematically perform the above HTML substitution, you would
1255 overload update_html in a subclass thusly:
1256
1257 package MyMech;
1258 use base 'WWW::Mechanize';
1259
1260 sub update_html {
1261 my ($self, $html) = @_;
1262 $html =~ s[</option>.{0,3}</td>][</option></select></td>]isg;
1263 $self->WWW::Mechanize::update_html( $html );
1264 }
1265
1266 If you do this, then the mech will use the tidied-up HTML instead of
1267 the original both when parsing for its own needs, and for returning to
1268 you through "content()".
1269
1270 Overloading this method is also the recommended way of implementing
1271 extra validation steps (e.g. link checkers) for every HTML page
1272 received. "warn" and "die" would then come in handy to signal
1273 validation errors.
1274
1275 $mech->credentials( $username, $password )
1276 Provide credentials to be used for HTTP Basic authentication for all
1277 sites and realms until further notice.
1278
1279 The four argument form described in LWP::UserAgent is still supported.
1280
1281 $mech->get_basic_credentials( $realm, $uri, $isproxy )
1282 Returns the credentials for the realm and URI.
1283
1284 $mech->clear_credentials()
1285 Remove any credentials set up with "credentials()".
1286
1288 As a subclass of LWP::UserAgent, WWW::Mechanize inherits all of
1289 LWP::UserAgent's methods. Many of which are overridden or extended.
1290 The following methods are inherited unchanged. View the LWP::UserAgent
1291 documentation for their implementation descriptions.
1292
1293 This is not meant to be an inclusive list. LWP::UA may have added
1294 others.
1295
1296 $mech->head()
1297 Inherited from LWP::UserAgent.
1298
1299 $mech->mirror()
1300 Inherited from LWP::UserAgent.
1301
1302 $mech->simple_request()
1303 Inherited from LWP::UserAgent.
1304
1305 $mech->is_protocol_supported()
1306 Inherited from LWP::UserAgent.
1307
1308 $mech->prepare_request()
1309 Inherited from LWP::UserAgent.
1310
1311 $mech->progress()
1312 Inherited from LWP::UserAgent.
1313
1315 These methods are only used internally. You probably don't need to
1316 know about them.
1317
1318 $mech->_update_page($request, $response)
1319 Updates all internal variables in $mech as if $request was just
1320 performed, and returns $response. The page stack is not altered by this
1321 method, it is up to caller (e.g. "request") to do that.
1322
1323 $mech->_modify_request( $req )
1324 Modifies a HTTP::Request before the request is sent out, for both GET
1325 and POST requests.
1326
1327 We add a "Referer" header, as well as header to note that we can accept
1328 gzip encoded content, if Compress::Zlib is installed.
1329
1330 $mech->_make_request()
1331 Convenience method to make it easier for subclasses like
1332 WWW::Mechanize::Cached to intercept the request.
1333
1334 $mech->_reset_page()
1335 Resets the internal fields that track page parsed stuff.
1336
1337 $mech->_extract_links()
1338 Extracts links from the content of a webpage, and populates the
1339 "{links}" property with WWW::Mechanize::Link objects.
1340
1341 $mech->_push_page_stack()
1342 The agent keeps a stack of visited pages, which it can pop when it
1343 needs to go BACK and so on.
1344
1345 The current page needs to be pushed onto the stack before we get a new
1346 page, and the stack needs to be popped when BACK occurs.
1347
1348 Neither of these take any arguments, they just operate on the $mech
1349 object.
1350
1351 warn( @messages )
1352 Centralized warning method, for diagnostics and non-fatal problems.
1353 Defaults to calling "CORE::warn", but may be overridden by setting
1354 "onwarn" in the constructor.
1355
1356 die( @messages )
1357 Centralized error method. Defaults to calling "CORE::die", but may be
1358 overridden by setting "onerror" in the constructor.
1359
1361 The default settings can get you up and running quickly, but there are
1362 settings you can change in order to make your life easier.
1363
1364 autocheck
1365 "autocheck" can save you the overhead of checking status codes for
1366 success. You may outgrow it as your needs get more sophisticated,
1367 but it's a safe option to start with.
1368
1369 my $agent = WWW::Mechanize->new( autocheck => 1 );
1370
1371 cookie_jar
1372 You are encouraged to install Mozilla::PublicSuffix and use
1373 HTTP::CookieJar::LWP as your cookie jar. HTTP::CookieJar::LWP
1374 provides a better security model matching that of current Web
1375 browsers when Mozilla::PublicSuffix is installed.
1376
1377 use HTTP::CookieJar::LWP ();
1378
1379 my $jar = HTTP::CookieJar::LWP->new;
1380 my $agent = WWW::Mechanize->new( cookie_jar => $jar );
1381
1382 protocols_allowed
1383 This option is inherited directly from LWP::UserAgent. It allows
1384 you to whitelist the protocols you're willing to allow.
1385
1386 my $agent = WWW::Mechanize->new(
1387 protocols_allowed => [ 'http', 'https' ]
1388 );
1389
1390 This will prevent you from inadvertently following URLs like
1391 "file:///etc/passwd"
1392
1393 protocols_forbidden
1394 This option is also inherited directly from LWP::UserAgent. It
1395 allows you to blacklist the protocols you're unwilling to allow.
1396
1397 my $agent = WWW::Mechanize->new(
1398 protocols_forbidden => [ 'file', 'mailto', 'ssh', ]
1399 );
1400
1401 This will prevent you from inadvertently following URLs like
1402 "file:///etc/passwd"
1403
1404 strict_forms
1405 Consider turning on the "strict_forms" option when you create a new
1406 Mech. This will perform a helpful sanity check on form fields
1407 every time you are submitting a form, which can save you a lot of
1408 debugging time.
1409
1410 my $agent = WWW::Mechanize->new( strict_forms => 1 );
1411
1412 If you do not want to have this option globally, you can still turn
1413 it on for individual forms.
1414
1415 $agent->submit_form( fields => { foo => 'bar' } , strict_forms => 1 );
1416
1418 WWW::Mechanize is hosted at GitHub.
1419
1420 Repository: <https://github.com/libwww-perl/WWW-Mechanize>. Bugs:
1421 <https://github.com/libwww-perl/WWW-Mechanize/issues>.
1422
1424 Spidering Hacks, by Kevin Hemenway and Tara Calishain
1425 Spidering Hacks from O'Reilly
1426 (<http://www.oreilly.com/catalog/spiderhks/>) is a great book for
1427 anyone wanting to know more about screen-scraping and spidering.
1428
1429 There are six hacks that use Mech or a Mech derivative:
1430
1431 #21 WWW::Mechanize 101
1432 #22 Scraping with WWW::Mechanize
1433 #36 Downloading Images from Webshots
1434 #44 Archiving Yahoo! Groups Messages with WWW::Yahoo::Groups
1435 #64 Super Author Searching
1436 #73 Scraping TV Listings
1437
1438 The book was also positively reviewed on Slashdot:
1439 <http://books.slashdot.org/article.pl?sid=03/12/11/2126256>
1440
1442 • WWW::Mechanize mailing list
1443
1444 The Mech mailing list is at
1445 <http://groups.google.com/group/www-mechanize-users> and is
1446 specific to Mechanize, unlike the LWP mailing list below. Although
1447 it is a users list, all development discussion takes place here,
1448 too.
1449
1450 • LWP mailing list
1451
1452 The LWP mailing list is at
1453 <http://lists.perl.org/showlist.cgi?name=libwww>, and is more user-
1454 oriented and well-populated than the WWW::Mechanize list.
1455
1456 • Perlmonks
1457
1458 <http://perlmonks.org> is an excellent community of support, and
1459 many questions about Mech have already been answered there.
1460
1461 • WWW::Mechanize::Examples
1462
1463 A random array of examples submitted by users, included with the
1464 Mechanize distribution.
1465
1467 • <http://www.ibm.com/developerworks/linux/library/wa-perlsecure/>
1468
1469 IBM article "Secure Web site access with Perl"
1470
1471 • <http://www.oreilly.com/catalog/googlehks2/chapter/hack84.pdf>
1472
1473 Leland Johnson's hack #84 in Google Hacks, 2nd Edition is an
1474 example of a production script that uses WWW::Mechanize and
1475 HTML::TableContentParser. It takes in keywords and returns the
1476 estimated price of these keywords on Google's AdWords program.
1477
1478 • <http://www.perl.com/pub/a/2004/06/04/recorder.html>
1479
1480 Linda Julien writes about using HTTP::Recorder to create
1481 WWW::Mechanize scripts.
1482
1483 • <http://www.developer.com/lang/other/article.php/3454041>
1484
1485 Jason Gilmore's article on using WWW::Mechanize for scraping sales
1486 information from Amazon and eBay.
1487
1488 • <http://www.perl.com/pub/a/2003/01/22/mechanize.html>
1489
1490 Chris Ball's article about using WWW::Mechanize for scraping TV
1491 listings.
1492
1493 • <http://www.stonehenge.com/merlyn/LinuxMag/col47.html>
1494
1495 Randal Schwartz's article on scraping Yahoo News for images. It's
1496 already out of date: He manually walks the list of links hunting
1497 for matches, which wouldn't have been necessary if the
1498 "find_link()" method existed at press time.
1499
1500 • <http://www.perladvent.org/2002/16th/>
1501
1502 WWW::Mechanize on the Perl Advent Calendar, by Mark Fowler.
1503
1504 • <http://www.linux-magazin.de/ausgaben/2004/03/datenruessel/>
1505
1506 Michael Schilli's article on Mech and WWW::Mechanize::Shell for the
1507 German magazine Linux Magazin.
1508
1509 Other modules that use Mechanize
1510 Here are modules that use or subclass Mechanize. Let me know of any
1511 others:
1512
1513 • Finance::Bank::LloydsTSB
1514
1515 • HTTP::Recorder
1516
1517 Acts as a proxy for web interaction, and then generates
1518 WWW::Mechanize scripts.
1519
1520 • Win32::IE::Mechanize
1521
1522 Just like Mech, but using Microsoft Internet Explorer to do the
1523 work.
1524
1525 • WWW::Bugzilla
1526
1527 • WWW::Google::Groups
1528
1529 • WWW::Hotmail
1530
1531 • WWW::Mechanize::Cached
1532
1533 • WWW::Mechanize::Cached::GZip
1534
1535 • WWW::Mechanize::FormFiller
1536
1537 • WWW::Mechanize::Shell
1538
1539 • WWW::Mechanize::Sleepy
1540
1541 • WWW::Mechanize::SpamCop
1542
1543 • WWW::Mechanize::Timed
1544
1545 • WWW::SourceForge
1546
1547 • WWW::Yahoo::Groups
1548
1549 • WWW::Scripter
1550
1552 Thanks to the numerous people who have helped out on WWW::Mechanize in
1553 one way or another, including Kirrily Robert for the original
1554 "WWW::Automate", Lyle Hopkins, Damien Clark, Ansgar Burchardt, Gisle
1555 Aas, Jeremy Ary, Hilary Holz, Rafael Kitover, Norbert Buchmuller, Dave
1556 Page, David Sainty, H.Merijn Brand, Matt Lawrence, Michael Schwern,
1557 Adriano Ferreira, Miyagawa, Peteris Krumins, Rafael Kitover, David
1558 Steinbrunner, Kevin Falcone, Mike O'Regan, Mark Stosberg, Uri Guttman,
1559 Peter Scott, Philippe Bruhat, Ian Langworth, John Beppu, Gavin Estey,
1560 Jim Brandt, Ask Bjoern Hansen, Greg Davies, Ed Silva, Mark-Jason
1561 Dominus, Autrijus Tang, Mark Fowler, Stuart Children, Max Maischein,
1562 Meng Wong, Prakash Kailasa, Abigail, Jan Pazdziora, Dominique
1563 Quatravaux, Scott Lanning, Rob Casey, Leland Johnson, Joshua Gatcomb,
1564 Julien Beasley, Abe Timmerman, Peter Stevens, Pete Krawczyk, Tad
1565 McClellan, and the late great Iain Truskett.
1566
1568 Andy Lester <andy at petdance.com>
1569
1571 This software is copyright (c) 2004 by Andy Lester.
1572
1573 This is free software; you can redistribute it and/or modify it under
1574 the same terms as the Perl 5 programming language system itself.
1575
1576
1577
1578perl v5.34.0 2021-08-08 WWW::Mechanize(3)