这是我到目前为止所拥有的。 它使用gem image_downloader
require 'rubygems'
require 'image_downloader'
downloader = ImageDownloader::Process.new('www.test.com','img_dir/')
downloader.parse(:any_looks_like_image => true)
downloader.download()
答案 0 :(得分:0)
ImageDownloader :: Process.new方法的第二个参数应该是您本地计算机的目标路径:
您之前的代码:
require 'rubygems'
require 'image_downloader'
downloader = ImageDownloader::Process.new('www.test.com','img_dir/')
downloader.parse(:any_looks_like_image => true)
downloader.download()
之后:
require 'rubygems'
require 'image_downloader'
require 'open-uri'
downloader = ImageDownloader::Process.new('<page url>','<your local directory complete path(target to place all images)>')
downloader.parse(:any_looks_like_image => true)
downloader.download()