Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Mechanize Download File w/o Loading it All in Memory

Reply
Thread Tools

Mechanize Download File w/o Loading it All in Memory

 
 
Raymond O'Connor
Guest
Posts: n/a
 
      08-28-2009
Is there a way to get Mechanize to download a csv file, without loading
it all into memory first? As I understand even if I used a pluggable
parser, it will still download the whole file into memory before saving
it to a file?

Thanks!
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Ryan Davis
Guest
Posts: n/a
 
      08-28-2009

On Aug 27, 2009, at 20:07 , Raymond O'Connor wrote:

> Is there a way to get Mechanize to download a csv file, without
> loading
> it all into memory first? As I understand even if I used a pluggable
> parser, it will still download the whole file into memory before
> saving
> it to a file?


I don't actually know if this will solve your problem as I've not used
it, but this looks like it is on the right track:

> require 'rubygems'
> require 'mechanize'
>
> agent = WWW::Mechanize.new
> agent.pluggable_parser.pdf = WWW::Mechanize::FileSaver
> agent.get('http://example.com/foo.pdf')


then again, it might not. mechanize doesn't sound like a very good
tool to be using for csv's in the first place as it can't actually DO
much with them. Why not use a more straightforward tool like curl?


 
Reply With Quote
 
 
 
 
Raymond O'Connor
Guest
Posts: n/a
 
      08-28-2009
Ryan Davis wrote:
> On Aug 27, 2009, at 20:07 , Raymond O'Connor wrote:
>
>> Is there a way to get Mechanize to download a csv file, without
>> loading
>> it all into memory first? As I understand even if I used a pluggable
>> parser, it will still download the whole file into memory before
>> saving
>> it to a file?

>
> I don't actually know if this will solve your problem as I've not used
> it, but this looks like it is on the right track:
>
>> require 'rubygems'
>> require 'mechanize'
>>
>> agent = WWW::Mechanize.new
>> agent.pluggable_parser.pdf = WWW::Mechanize::FileSaver
>> agent.get('http://example.com/foo.pdf')

>
> then again, it might not. mechanize doesn't sound like a very good
> tool to be using for csv's in the first place as it can't actually DO
> much with them. Why not use a more straightforward tool like curl?


It's a whole process just to get to the page where you can download the
csv file. I have to log in to the site, request the file, etc. which
is why I was hoping I could do it in mechanize
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
download button - how to get file with mechanize zak Ruby 0 07-22-2010 09:20 AM
Re: Pdf download using mechanize Aaron Watters Python 0 07-06-2010 03:59 PM
loading offline html files with mechanize Adam Akhtar Ruby 0 03-23-2009 11:40 AM
mechanize - could not loading RubyGem hoe... Ruby Newbie Ruby 2 10-15-2008 01:27 PM
How to edit a file without loading it all into memory Jonathan Dobbie Ruby 7 11-10-2007 12:54 AM



Advertisments