November 2008
Intermediate to advanced
208 pages
4h 32m
English
This script will scrape every image from the page at a user-supplied URL. The image files will include data residing on the host machine in addition to images linked from other web servers.
require "open-uri"
require "pathname"
unless ARGV[0]
puts "You must supply a URL to scrape images."
puts "USAGE: ruby imageScrape.rb <url to scrape>"
exit
end
url = ARGV[0].strip
begin
open(url, "User-Agent" => "Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)")
do |source|
source.each_line do |x|
if x =~ /<img src="(.+.[jpeg|gif])"\s+/ ...Read now
Unlock full access