Wanted to have some airplane reading for the trip to RubyConf and whipped
up the following script to download comic strips from an online comic
source:
#!/usr/bin/ruby -w
require ‘net/http’
domain = "www.comicprovider.com"
path = “/comic-strip/2001/”
‘01’.upto(‘12’) do |month|
start = '01’
finish = ‘31’
puts “Fetching #{path} from #{domain} starting at #{start} and going to
#{finish} for month #{month}”
h = Net::HTTP.new(domain, 80)
start.upto(finish) do |g|
begin
s = "#{path}#{month}#{g}.gif"
puts "Fetching #{s}…"
resp, data = h.get(s)
puts "Writing #{g}…"
File.open(“stripname_2001#{month}#{g}.gif”, “w+”){|b| b.puts data}
rescue
puts "error fetching or writing #{s}, continuing"
end
end
end
But I get segfaults all the time, which means I have to adjust the
boundaries and start over. It’s not predictable.
/usr/lib/ruby/1.6/net/protocol.rb:785: [BUG] Segmentation fault
ruby 1.6.7 (2002-03-01) [i686-linux-gnu]
Aborted
What the heck?
-michael
Michael C. Libby x@ichimunki.com http://www.ichimunki.com/ http://www.ichimunki.com/public_key.txt