Class: Archaeo::SaveApi
- Inherits:
-
Object
- Object
- Archaeo::SaveApi
- Defined in:
- lib/archaeo/save_api.rb
Overview
Client for the Wayback Machine SavePageNow (SPN) API.
Request the Wayback Machine to archive a URL and retrieve the resulting archive URL and timestamp as a SaveResult.
Constant Summary collapse
- ENDPOINT =
"https://web.archive.org/save"- DEFAULT_MAX_TRIES =
8- TIMESTAMP_RE =
%r{web\.archive\.org/web/(\d{14})}
Instance Method Summary collapse
-
#initialize(client: HttpClient.new, max_tries: DEFAULT_MAX_TRIES) ⇒ SaveApi
constructor
A new instance of SaveApi.
- #save(url) ⇒ Object
Constructor Details
#initialize(client: HttpClient.new, max_tries: DEFAULT_MAX_TRIES) ⇒ SaveApi
Returns a new instance of SaveApi.
13 14 15 16 17 |
# File 'lib/archaeo/save_api.rb', line 13 def initialize(client: HttpClient.new, max_tries: DEFAULT_MAX_TRIES) @client = client @max_tries = max_tries end |
Instance Method Details
#save(url) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/archaeo/save_api.rb', line 19 def save(url) url = UrlNormalizer.normalize(url) save_url = "#{ENDPOINT}/#{url}" start_time = Time.now.utc attempt_save(save_url, start_time, url) end |