Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

WWW:Mechanize conditional finding/following links and redundant link avoiding?!

by fraizerangus (Sexton)
on Oct 24, 2011 at 18:50 UTC ( [id://933458]=perlquestion: print w/replies, xml ) Need Help??

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

Hi Monks

Apologies but 2 questions for you today regarding WWW:Mechanize:

1) When using the $mech->follow_link(...) $mech->find_link( ... ) if one wanted more than 1 conditional for selecting links what would the syntax be for doing this e.g

my @cgi_links = $mech_cgi->find_all_links( url_regex => qr/protein/ );

but the following does'nt?

my @cgi_links = $mech_cgi->find_all_links( url_regex => qr/(protein && + amino)/ );

Can anyone point me in the right direction or know the answer?

2) what is the best practice for only following/selecting the same link once and not following it again multiple times if the link is present more than once on a web-page?

many thanks and best wishes

Dan

Replies are listed 'Best First'.
Re: WWW:Mechanize conditional finding/following links and redundant link avoiding?!
by roboticus (Chancellor) on Oct 24, 2011 at 19:02 UTC

    fraizerangus:

    Read perldoc perlre to learn how to create regular expressions. Your regular expression isn't searching for what you think it is...

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-26 01:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found