-2

I am currently working on a Rails app. I want to go to a website(http://alt19.com/) and select a set of options, then click a button which triggers the download of a CSV file. Then I want to take the file and parse it.

I have found a gem for parsing CSV files. However, I don't know if there is a gem for navigating to another website, selecting a set of options, downloading several files and saving them somewhere where my app can process them.

Is there anything like this? If not, are there any alternative solutions?

bsky
  • 19,326
  • 49
  • 155
  • 270
  • 2
    Checkout mechanize gem : http://mechanize.rubyforge.org/EXAMPLES_rdoc.html http://mechanize.rubyforge.org/Mechanize/Download.html – Prakash Murthy May 18 '15 at 09:50

2 Answers2

1

You can use mechanize gem to scrap the page. Mechanize uses nokogiri as one of the dependency which is responsible for scraping and mechanize has added feature of clicking elements from the page.

RAJ
  • 9,697
  • 1
  • 33
  • 63
0

As you can see the CSV Generator from makes a post with some params. Just do the same with 'net/https' and 'open_uri'

Example :

require "uri"
require "net/http"

params = {'box1' => 'Nothing is less important than which fork you use. Etiquette is the science of living. It embraces everything. It is ethics. It is honor. -Emily Post',
'button1' => 'Submit'
}
x =         Net::HTTP.post_form(URI.parse('http://www.interlacken.com/webdbdev/ch05/formpost.asp'), params)
puts x.body

Example source: Submitting POST data from the controller in rails to another website

Community
  • 1
  • 1
IMhide
  • 1