Project

wayback

0.01
No commit activity in last 3 years
No release in over 3 years
A Ruby interface to the Archive.org's Wayback Machine JSON and Memento APIs.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0

Runtime

< 0.10, ~> 0.8
< 0.10, ~> 0.9
~> 1.8
 Project Readme

Wayback Gem

Gem Version Build Status Coverage Status

A Ruby interface to Archive.org's Wayback Machine Memento API.

Installation

gem install wayback

Quick Start Guide

Accessing the Wayback Machine is super-duper easy.

require 'wayback'
Wayback.page('http://www.xolator.com', :first)

Documentation

You can browse the Rdoc here.

Configuration

There is no real configuration necessary for accessing the Wayback Machine Memento API, however you can change endpoint and other basic connection options.

The current defaults configurations for this gem are:

Wayback.configure do |c|
  c.endpoint = 'http://web.archive.org'
  c.endpoint_path = '/web'
  c.json_endpoint = 'http://archive.org'
  c.json_endpoint_path = '/wayback'
  c.connection_options = {
    :headers  => {:user_agent => "Wayback Ruby Gem #{Wayback::Version}"},
    :request  => {:open_timeout => 5, :timeout => 10},
    :ssl      => {:verify => false},
  }
  c.identiy_map = false
  c.middleware = Faraday::Builder.new do |builder|
    # Convert request params to "www-form-urlencoded"
    builder.use Faraday::Request::UrlEncoded
    # Follow redirects
    builder.use FaradayMiddleware::FollowRedirects
    # Handle 4xx server responses
    builder.use Wayback::Response::RaiseError, Wayback::Error::ClientError
    # Handle 5xx server responses
    builder.use Wayback::Response::RaiseError, Wayback::Error::ServerError
    # Parse closest available JSON result
    builder.use Wayback::Response::ParseAvailablity
    # Parse memento page
    builder.use Wayback::Response::ParseMementoPage
    # Parse link-format with custom memento parser
    builder.use Wayback::Response::ParseMemento
    # Set Faraday's HTTP adapter
    builder.adapter Faraday.default_adapter
  end

Usage Examples

Fetch the timeline of archived pages

Wayback.list('http://www.xolator.com')

Fetch closest known page to a specified date

Wayback.available('http://www.xolator.com', 20130613055153)
Wayback.available('http://www.xolator.com', :first)
Wayback.available('http://www.xolator.com', :last)

Fetch a specific archived page

Wayback.page('http://www.xolator.com', 20130613055153)
Wayback.page('http://www.xolator.com', :first)
Wayback.page('http://www.xolator.com', :last)

Additional Notes

Based heavily on the Twitter gem. (Xièxie!)

More information on Archive's Wayback Machine memento API can be found here.

Copyright

Copyright (c) 2013 XOlator. See LICENSE for details.