forked from BillTheKid2000/Project-Group-12
-
Notifications
You must be signed in to change notification settings - Fork 0
/
M1_test.html
37 lines (32 loc) · 1018 Bytes
/
M1_test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html>
<head>
<title>Wayback Machine API Demo</title>
</head>
<body>
<h1>Wayback Machine API Demo</h1>
<input type="text" id="url" placeholder="Enter a URL">
<button onclick="getSnapshot()">Get Snapshot</button>
<div id="snapshot"></div>
<script>
function getSnapshot() {
var url = document.getElementById("url").value;
// Make a request to the Wayback Machine API
var xhr = new XMLHttpRequest();
xhr.open("GET", "https://archive.org/web/api/rest/v1/snapshot/" + url);
xhr.onload = function() {
if (xhr.status === 200) {
// The request was successful, so parse the response
var response = JSON.parse(xhr.responseText);
// Display the snapshot on the page
document.getElementById("snapshot").innerHTML = response.content;
} else {
// The request failed, so display an error message
document.getElementById("snapshot").innerHTML = "Error: " + xhr.status;
}
};
xhr.send();
}
</script>
</body>
</html>