clicking links in mechanize with :text=> nokogiri.css('a.l')

E

Edouard Dantes

Hi,

i cannot click links in mechanize through their text content.

i tried the following but get error with link_with:)text => '') method
or using the whole text content obtained through nokogiri parser method
css('a.l') that points to google results.

what am i doing wrong?

thanks for input


#!/usr/bin/env ruby

require 'rubygems'
require 'mechanize'
$KCODE='UTF8'

@agent= WWW::Mechanize.new
@[email protected]('http://www.google.com/search?q=parsing')

puts @agent.click @page.link_with:)text => 'parsing') <===??

@page.parser.css('a.l').each do |l| puts @agent.click(l).inner_text end
<===??
 
L

Luis Parravicini

i cannot click links in mechanize through their text content.

i tried the following but get error with link_with:)text => '') method
or using the whole text content obtained through nokogiri parser method
css('a.l') that points to google results.
...
@agent= WWW::Mechanize.new
@[email protected]('http://www.google.com/search?q=parsing')

puts @agent.click @page.link_with:)text => 'parsing') <===??

There is no link with text 'parsing'. Just tried that google search
and there's a 'Parsing' result on the first page.
@page.link_with:)text => 'Parsing') returns a WWW::Mechanize::page::Link
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top