Spaces:
Sleeping
Sleeping
Upload index.html
Browse files- index.html +118 -149
index.html
CHANGED
@@ -1,150 +1,119 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
-
<html lang="en">
|
3 |
-
<head>
|
4 |
-
<meta charset="UTF-8">
|
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 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
speakResponse(data);
|
120 |
-
}
|
121 |
-
|
122 |
-
function showUserMessage(message) {
|
123 |
-
var chatBox = document.getElementById('chat-box');
|
124 |
-
var userMessageHTML = '<div class="user-message">' + message + '</div>';
|
125 |
-
chatBox.innerHTML += userMessageHTML;
|
126 |
-
}
|
127 |
-
|
128 |
-
function showBotMessage(message) {
|
129 |
-
var chatBox = document.getElementById('chat-box');
|
130 |
-
var botMessageHTML = '<div class="bot-message">' + message + '</div>';
|
131 |
-
chatBox.innerHTML += botMessageHTML;
|
132 |
-
}
|
133 |
-
|
134 |
-
function speakResponse(response) {
|
135 |
-
var utterance = new SpeechSynthesisUtterance(response);
|
136 |
-
speechSynthesis.speak(utterance);
|
137 |
-
window.addEventListener('beforeunload', function () {
|
138 |
-
if (synth.speaking) {
|
139 |
-
synth.cancel();
|
140 |
-
}
|
141 |
-
});
|
142 |
-
document.getElementById('speech').addEventListener('click', function () {
|
143 |
-
if (synth.speaking) {
|
144 |
-
synth.cancel();
|
145 |
-
}
|
146 |
-
});
|
147 |
-
}
|
148 |
-
</script>
|
149 |
-
</body>
|
150 |
</html>
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Web Scraper</title>
|
7 |
+
<style>
|
8 |
+
body {
|
9 |
+
font-family: Arial, sans-serif;
|
10 |
+
max-width: 800px;
|
11 |
+
margin: 0 auto;
|
12 |
+
padding: 20px;
|
13 |
+
}
|
14 |
+
.form-group {
|
15 |
+
margin-bottom: 15px;
|
16 |
+
}
|
17 |
+
label {
|
18 |
+
display: block;
|
19 |
+
margin-bottom: 5px;
|
20 |
+
}
|
21 |
+
input {
|
22 |
+
width: 100%;
|
23 |
+
padding: 8px;
|
24 |
+
box-sizing: border-box;
|
25 |
+
}
|
26 |
+
button {
|
27 |
+
padding: 10px 20px;
|
28 |
+
background-color: #007bff;
|
29 |
+
color: white;
|
30 |
+
border: none;
|
31 |
+
cursor: pointer;
|
32 |
+
}
|
33 |
+
button:hover {
|
34 |
+
background-color: #0056b3;
|
35 |
+
}
|
36 |
+
#error-message {
|
37 |
+
color: red;
|
38 |
+
margin-top: 10px;
|
39 |
+
display: none;
|
40 |
+
}
|
41 |
+
#success-message {
|
42 |
+
color: green;
|
43 |
+
margin-top: 10px;
|
44 |
+
display: none;
|
45 |
+
}
|
46 |
+
#result {
|
47 |
+
margin-top: 20px;
|
48 |
+
}
|
49 |
+
</style>
|
50 |
+
</head>
|
51 |
+
<body>
|
52 |
+
<h1>Web Scraper</h1>
|
53 |
+
<form id="scrape-form">
|
54 |
+
<div class="form-group">
|
55 |
+
<label for="url">Website URL:</label>
|
56 |
+
<input type="url" id="url" name="url" required placeholder="https://example.com">
|
57 |
+
</div>
|
58 |
+
<div class="form-group">
|
59 |
+
<label for="email">Email Address:</label>
|
60 |
+
<input type="email" id="email" name="email" required placeholder="[email protected]">
|
61 |
+
</div>
|
62 |
+
<button type="submit">Scrape Website</button>
|
63 |
+
</form>
|
64 |
+
<div id="error-message"></div>
|
65 |
+
<div id="success-message"></div>
|
66 |
+
<div id="result"></div>
|
67 |
+
|
68 |
+
<script>
|
69 |
+
const form = document.getElementById('scrape-form');
|
70 |
+
const errorMessage = document.getElementById('error-message');
|
71 |
+
const successMessage = document.getElementById('success-message');
|
72 |
+
const resultDiv = document.getElementById('result');
|
73 |
+
|
74 |
+
form.addEventListener('submit', async (e) => {
|
75 |
+
e.preventDefault();
|
76 |
+
errorMessage.style.display = 'none';
|
77 |
+
successMessage.style.display = 'none';
|
78 |
+
resultDiv.innerHTML = '';
|
79 |
+
|
80 |
+
const url = document.getElementById('url').value;
|
81 |
+
const email = document.getElementById('email').value;
|
82 |
+
|
83 |
+
// Show success message immediately on form submission
|
84 |
+
successMessage.textContent = `RCS generation started, a mail will be sent to ${email} within 5 to 10 min.`;
|
85 |
+
successMessage.style.display = 'block';
|
86 |
+
|
87 |
+
try {
|
88 |
+
const response = await fetch(`/scrape?url=${encodeURIComponent(url)}&email=${encodeURIComponent(email)}`, {
|
89 |
+
method: 'GET',
|
90 |
+
headers: {
|
91 |
+
'Content-Type': 'application/json'
|
92 |
+
}
|
93 |
+
});
|
94 |
+
|
95 |
+
if (!response.ok) {
|
96 |
+
const errorData = await response.json();
|
97 |
+
// Hide success message if an error occurs
|
98 |
+
successMessage.style.display = 'none';
|
99 |
+
if (response.status === 403 && errorData.detail === 'Personal email addresses do not have access to generate RCS.') {
|
100 |
+
errorMessage.textContent = 'Personal email addresses do not have access to generate RCS.';
|
101 |
+
} else if (response.status === 400 && errorData.detail === 'This email is already used to create RCS. For more information, contact support team.') {
|
102 |
+
errorMessage.textContent = 'This email is already used to create RCS. For more information, contact support team.';
|
103 |
+
} else {
|
104 |
+
errorMessage.textContent = errorData.detail || 'An error occurred while scraping the website.';
|
105 |
+
}
|
106 |
+
errorMessage.style.display = 'block';
|
107 |
+
return;
|
108 |
+
}
|
109 |
+
} catch (error) {
|
110 |
+
console.error('Error:', error);
|
111 |
+
// Hide success message if a network error occurs
|
112 |
+
successMessage.style.display = 'none';
|
113 |
+
errorMessage.textContent = 'Failed to connect to the server.';
|
114 |
+
errorMessage.style.display = 'block';
|
115 |
+
}
|
116 |
+
});
|
117 |
+
</script>
|
118 |
+
</body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
</html>
|