mirror of
https://github.com/StrawberryMaster/wayback-machine-downloader.git
synced 2025-12-17 17:56:44 +00:00
28 lines
714 B
Ruby
28 lines
714 B
Ruby
module ArchiveAPI
|
|
|
|
def get_raw_list_from_api url
|
|
request_url = "http://web.archive.org/cdx/search/xd?url="
|
|
request_url += url
|
|
request_url += parameters_for_api
|
|
request_uri = URI.parse request_url
|
|
response = Net::HTTP.get_response request_uri
|
|
response.body
|
|
end
|
|
|
|
def parameters_for_api
|
|
parameters = "&fl=timestamp,original&gzip=false"
|
|
if @all
|
|
parameters += "&collapse=digest"
|
|
else
|
|
parameters += "&filter=statuscode:200&collapse=original"
|
|
end
|
|
if @from_timestamp and @from_timestamp != 0
|
|
parameters += "&from=" + @from_timestamp.to_s
|
|
end
|
|
if @to_timestamp and @to_timestamp != 0
|
|
parameters += "&to=" + @to_timestamp.to_s
|
|
end
|
|
parameters
|
|
end
|
|
|
|
end |