screen scraping - How to insert a string to a text field using mechanize in ruby? -


i know simple question i've been stuck hour , can't understand how works.

i need scrape stuff school's library need insert 'ce' text field , click on link text 'clasificación'. output going use work. here code.

require 'rubygems' require 'open-uri' require 'nokogiri' require 'mechanize'  url = 'http://biblio02.eld.edu.mx/janium-bin/busqueda_rapida.pl?id=20110720161008#' searchstr = 'ce'  agent = mechanize.new page = agent.get(url)  searchform = page.form_with(:method => 'post') searchform['buscar'] = searchstr  clasificacionlink = page.link_with(:href => "javascript:onclick=set_index_and_submit(\'51\');").click page = agent.submit(searchform,clasificacionlink) 

when run it, gives me error

janium.rb:31: undefined method `[]=' nil:nilclass (nomethoderror) 

thanks!

mu's answer sounds reasonable. not sure if strictly necessary, might try put braces around searchstr.

searchform['buscar'] = [searchstr] 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -