gem - Manipulate webpage and have it send back results using ruby -


so here is:

i use ruby user input, easy way..say request 2 inputs:

input1 = gets.chomp  input2 = gets.chomp 

now send information say, search engine takes these 2 options separately , search. how can this? api/gems helpful me in case?

i know can take these 2 inputs , insert them url not simple because according inputs url structure not constant..(i wouldn't want use way though..)
been long time since lat programmed in ruby, know how access webpages , things that, want manipulate , receive back. ideas?

if talking front-end of site without api access or sophisticated js logic, use mechanize gem allows like:

require 'rubygems' require 'mechanize'  agent = mechanize.new page  = agent.get('http://google.com/')  form = page.forms.first form['field_name_1'] = input1 form['field_name_2'] = input2  page = agent.submit(form, form.buttons.first) puts page 

→ check out official documentation more examples

if going use third party rest api should better try faraday or other popular gems (depending on taste , particular task).


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -