Skip to content

Instantly share code, notes, and snippets.

@tosik
Created April 25, 2010 07:16
Show Gist options
  • Save tosik/378232 to your computer and use it in GitHub Desktop.
Save tosik/378232 to your computer and use it in GitHub Desktop.
gumonji's diary downloader
#!/bin/ruby
require 'open-uri'
user_id = 1168
pages = (1..16)
url_prefix = "http://www.gumonji.net/cgi-bin/"
url_no_page_num = url_prefix + "diary_list.cgi?order=id&user_id=" + user_id.to_s + "&page="
pages.each {|page|
url = url_no_page_num + page.to_s
open(url) {|f|
f.each_line {|line|
if /(diary\.cgi\?id=)(\d*)/ =~ line
dairy_url = url_prefix + $1 + $2
p dairy_url
in_file = open(dairy_url)
out_file = open("diary/diary" + $2 + ".html", "w")
out_file.write(in_file.read)
in_file.close
out_file.close
end
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment