libwww-perl / WWW-Mechanize

Handy web browsing in a Perl object
https://metacpan.org/pod/WWW::Mechanize
Other
68 stars 52 forks source link

Mention one should find_link before follow_link #188

Closed spazm closed 1 year ago

spazm commented 7 years ago

jidanni reported on Dec 19, 2010

Mention on the man page that one should remember to check first,

do { get_all_blogs_on_this_page() }
  while ( $mech->find_link( text_regex => qr'下一頁' )
    && $mech->follow_link( text_regex => qr'下一頁' ) );

unless one wants to get nasty Link Not Found fatal messages.

Perhaps even use the results of the check instead of finding a second time.

Details

Imported from Google Code issue 192 via archive

Comments

petda...@gmail.com commented on Dec 19, 2010 :

Documentation patches welcome.  Better that the person who finds the docs confusing submit the changes to the docs.

jidanni commented on Dec 19, 2010 :

Say: if follow_link() fails to find the link, the program will terminate with "Link Not Found". Therefore be sure to test first with find_link() when in doubt.

petda...@gmail.com commented on Apr 24, 2011 :

(No comment was entered for this change.)

mark.sto...@gmail.com commented on Feb 4, 2013 :

I would rather that follow_link be modified to fail rather than die if the link can't be found. The diagnostics can clarify that the link can't be followed because it wasn't found, not because the link failed to return a "successful" response.
simbabque commented 1 year ago

follow_link() now calls find_link() first, so this seems already solved.