blob: b059cf6e53879027c1ad6e2bf2f483103dd06652 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#!/usr/bin/env ruby
require 'open-uri'
HOME_URL = 'http://borgar.net/programs/sokoban/'
BASE_URL = 'http://borgar.net/programs/sokoban/levels'
# read HTML, extract level sets
open(HOME_URL).read.scan(/<option value="([^"]+)"/).flatten.each do |name|
# build source url and destination file name
src_url = '%s/%s.txt' % [BASE_URL, name.gsub(/ /, '%20')]
dst_path = '%s.txt' % [name]
# read url, write to path
puts dst_path
File.write(dst_path, open(src_url).read)
end
|