-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresults.html
57 lines (51 loc) · 1.99 KB
/
results.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Results</title>
<script>
document.addEventListener("DOMContentLoaded", () => {
const params = new URLSearchParams(window.location.search);
const data = JSON.parse(decodeURIComponent(params.get('data')));
const resultsDiv = document.getElementById('results');
data.forEach(result => {
const a = document.createElement('a');
a.href = result;
a.textContent = result;
a.target = "_blank"; // Open link in a new tab
a.style.display = 'block'; // Display each link on a new line
resultsDiv.appendChild(a);
});
});
async function submitForm(event) {
event.preventDefault();
const linkInput = document.getElementById('link');
const loadingMessage = document.getElementById('loadingMessage');
const parcel = linkInput.value;
// Show loading message
loadingMessage.style.display = 'block';
const response = await fetch('/info', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ parcel })
});
if (response.redirected) {
window.location.href = response.url;
} else {
const result = await response.json();
console.error(result.error);
alert('An error occurred: ' + result.error);
// Hide loading message
loadingMessage.style.display = 'none';
}
}
</script>
</head>
<body>
<h1>Web Scraping Results</h1>
<button onclick="window.location.href='/'">Start a New Search</button>
<div id="results"></div>
<p id="loadingMessage" style