S
Squawk Boxed
The Mechanize documentation says to just start scraping with Nokogiri
once you've navigated to the right page with Mechanize, but this example
doesn't seem to work for me:
agent = Mechanize.new
page = agent.get('http://google.com/')
google_form = page.form('f')
google_form.q = 'ruby mechanize'
page = agent.submit(google_form)
page.xpath('//h3/a[@class="l"]').each do |link|
puts link.content
end
But this works:
page =
Nokogiri::HTML(open('http://www.google.com/search?q=ruby+mechanize'))
page.xpath('//h3/a[@class="l"]').each do |link|
puts link.content
end
Any advice?
once you've navigated to the right page with Mechanize, but this example
doesn't seem to work for me:
agent = Mechanize.new
page = agent.get('http://google.com/')
google_form = page.form('f')
google_form.q = 'ruby mechanize'
page = agent.submit(google_form)
page.xpath('//h3/a[@class="l"]').each do |link|
puts link.content
end
But this works:
page =
Nokogiri::HTML(open('http://www.google.com/search?q=ruby+mechanize'))
page.xpath('//h3/a[@class="l"]').each do |link|
puts link.content
end
Any advice?