Save WWW :: Mechanize :: File to disk using FileUtils

Using Mechanize with Ruby. I get a specific file using agent.get('http://example.com/foo.torrent'), with FileUtils or in another way, how to save this file to my hard drive (for example, in the directory where the script works)?

PS class => WWW::Mechanize::File

+3
source share
2 answers

Well, it WWW::Mechanize::Filehas an instance method save_as, so I assume something like this might work:

agent.get('http://example.com/foo.torrent').save_as 'a_file_name'
+4
source

, Mechanize::File . Mechanize::Download, . , script ( ). , . :

agent.pluggable_parser.default = Mechanize::Download
agent.get( "http://example.com/foo.torrent}").save("path/to/a_file_name")

, , Stackoverflow.

0

Source: https://habr.com/ru/post/1725571/


All Articles