Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: WWW::Mechanize::Link get id from attrs (firefox find_link_dom)

by Corion (Patriarch)
on Feb 12, 2015 at 07:28 UTC ( [id://1116447]=note: print w/replies, xml ) Need Help??


in reply to Re: WWW::Mechanize::Link get id from attrs (firefox find_link_dom)
in thread WWW::Mechanize::Link get id from attrs

WWW::Mechanize::Link is not part of WWW::Mechanize::Firefox :-).

I don't think that WWW::Mechanize::Link supports the id attribute, at least, it doesn't appear anywhere in its documentation.

  • Comment on Re^2: WWW::Mechanize::Link get id from attrs (firefox find_link_dom)
  • Download Code

Replies are listed 'Best First'.
Re^3: WWW::Mechanize::Link get id from attrs (firefox find_link_dom)
by Anonymous Monk on Feb 12, 2015 at 07:57 UTC
    Um, http://search.cpan.org/perldoc/WWW::Mechanize::Link#$link->attrs()?

    see href and id in hash below

    $ cat alinkswithhrefsandids.html <html> <body> <a href="http://example.com/first+one" id="first"> one </a> <a href="http://example.com/second+two" id="second"> two </a> <a href="http://example.com/third+three" id="third"> three </a> $ mech-dump --links file:alinkswithhrefsandids.html http://example.com/first+one http://example.com/second+two http://example.com/third+three $ perl -MData::Dump -MWWW::Mechanize -e " $u=WWW::Mechanize->new; $u-> +get( qw/ file:alinkswithhrefsandids.html /); dd( $u->links ); " do { my $a = bless([ "http://example.com/first+one", "one", undef, "a", bless(do{\(my $o = "file:alinkswithhrefsandids.html")}, "URI::file +"), { href => "http://example.com/first+one", id => "first" }, ], "WWW::Mechanize::Link"); ( $a, bless([ "http://example.com/second+two", "two", undef, "a", \${$a->[4]}, { href => "http://example.com/second+two", id => "second" }, ], "WWW::Mechanize::Link"), bless([ "http://example.com/third+three", "three", undef, "a", \${$a->[4]}, { href => "http://example.com/third+three", id => "third" }, ], "WWW::Mechanize::Link"), ); }

      Ah - you're correct. I don't think that (if it is used) WWW::Mechanize::Firefox fills the ->attrs hash, and if it's plain WWW::Mechanize, then the link in question doesn't have an id= attribute set.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-20 16:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found