RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: sergioschuler
I am trying to click a list of links with Mechanize gem, but apparently Mechanize's links_with(criteria) is not properly filtering based on the criteria. For debugging purposes, I am only printing out the link.
The following script is printing out most (all?) links on the page:
agent = Mechanize.new
url = "http://www.fearlessphotographers.com/location/470/sul-do-brasil"
agent.page.links_with(:text => /[VIEW FULL PROFILE]/).each do |link|
And if I change the (:text => /[VIEW FULL PROFILE]/) to (:text => "VIEW FULL PROFILE") then no link at all gets printed.
(:text => /[VIEW FULL PROFILE]/)
(:text => "VIEW FULL PROFILE")
I can't understand what I am doing wrong. Any thoughts?
Thanks for that!