Module: WebArchive

Extended by:
WebArchive
Included in:
WebArchive
Defined in:
lib/web-archive.rb,
lib/web-archive/version.rb

Constant Summary collapse

BASE =
'http://web.archive.org'
VERSION =
"0.1.0"

Instance Method Summary collapse

Instance Method Details

#get_archived_urls(url) ⇒ Object



21
22
23
24
25
26
# File 'lib/web-archive.rb', line 21

def get_archived_urls(url)
  html = open("#{BASE}/web/*/#{url}", &:read) rescue (return [])
  html.scan(%r{"(/web/\d+/.*?)"}).flatten.uniq.sort.map do |str|
    BASE + str
  end
end

#latest(url) ⇒ Object



13
14
15
# File 'lib/web-archive.rb', line 13

def latest(url)
  get_archived_urls(url).last
end

#oldest(url) ⇒ Object



17
18
19
# File 'lib/web-archive.rb', line 17

def oldest(url)
  get_archived_urls(url).first
end

#save!(url) ⇒ Object



8
9
10
11
# File 'lib/web-archive.rb', line 8

def save!(url)
  s = open( "#{BASE}/save/#{url}", &:read )
  BASE + s[%r{"(/web/\d+/.*?)"},1]
end