Reputation: 11098
I'm trying to loop through links on a page but i only want to loop through specific ones. The problem is that the links in <a>
anchors do not have CSS ids or classes at all.
eg.
<a title="View More Information on FOO" href="tranlist.phtml?scode=FOO&sname=&refpg=1&snapcode=&ssector=1123&scheme=default" name="tranlist">
The only thing unique is the name
but it doesn't seem like it can be specified with CSS selector.
Upvotes: 2
Views: 468
Reputation: 126722
From the CSS specification, a CSS selector like a.normal
is the same as a[class~=normal]
, and you can match any attribute that way. So you need
$mech->selector('a[name=tranlist]')
Upvotes: 2
Reputation: 968
From the module documentation:
$mech->find_link(name => "something")
name_contains
and name_regex
are also available.
[Edit: find_link_dom
returns Firefox-specific MozRepl::RemoteObject::Instance
objects, rather than standard WWW::Mechanize::Link
objects which are returned by find_link
. Amended for the more generic case.]
Upvotes: 2