-3

I'm currently logging into several websites a day and then downloading CSV files from each. Is there a way to do this programmatically in ruby?

As an example of websites that I log into - they're external party sites that have an interface for a user to login using an email and password (probably devise or some sort of standard auth). After login, the user is taken to a page where there is a link that I click on to download the CSV.

I know how to parse CSV data with ruby, but I'm not sure how to login to a site, then download the file from a link.

locoboy
  • 38,002
  • 70
  • 184
  • 260
  • 1
    We don't know what websites you're talking about. Perhaps if you gave us more information we could help you, but, with the question as it is, the answer is "yes", there is a way, but we can't tell you what it is because you didn't give us enough to work on. – the Tin Man Dec 04 '14 at 23:06
  • http://stackoverflow.com/a/4217251/2413778 – John C Dec 05 '14 at 01:21
  • @theTinMan edited the question so that it's more specific. let me know if you need something else. – locoboy Dec 05 '14 at 02:38
  • That doesn't help at all. Please read "[How do I ask a good question?](http://stackoverflow.com/help/how-to-ask)", and the related links at the bottom of the page. Every website requires inside knowledge of the page structure if Mechanize or other code is to be used. There is no "generic" answer that applies to every one. Without knowledge of the target sites, which you haven't divulged, there's nothing further we can do to help you. Even if you did, your question would still be lacking, as Stack Overflow is about helping you fix broken code, not telling how you to code. – the Tin Man Dec 05 '14 at 16:10
  • @theTinMan - the below answer was able to provide me enough thanks. – locoboy Dec 05 '14 at 20:43

1 Answers1

1

If you're trying to log into websites, then you'll need to use something like Mechanize (tutorial). Once your script is logged in you'll want to use Mechanize::Download - see here: Using WWW:Mechanize to download a file to disk without loading it all in memory first That's assuming you want to store the file locally. If the HTTP request allows you to simply read a URL (like http://example.com/data.csv) then you might be able to read that csv file directly in memory.

Community
  • 1
  • 1
Besto
  • 309
  • 1
  • 13