amalsp commited on
Commit
65512d9
·
verified ·
1 Parent(s): 9db3a52

Create static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +245 -0
static/index.html ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 - Extract Data to Excel</title>
7
+ <style>
8
+ * {
9
+ margin: 0;
10
+ padding: 0;
11
+ box-sizing: border-box;
12
+ }
13
+ body {
14
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
15
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
16
+ min-height: 100vh;
17
+ display: flex;
18
+ justify-content: center;
19
+ align-items: center;
20
+ padding: 20px;
21
+ }
22
+ .container {
23
+ background: white;
24
+ border-radius: 20px;
25
+ box-shadow: 0 20px 60px rgba(0,0,0,0.3);
26
+ padding: 40px;
27
+ max-width: 600px;
28
+ width: 100%;
29
+ }
30
+ h1 {
31
+ color: #333;
32
+ margin-bottom: 10px;
33
+ font-size: 28px;
34
+ }
35
+ .subtitle {
36
+ color: #666;
37
+ margin-bottom: 30px;
38
+ font-size: 14px;
39
+ }
40
+ .form-group {
41
+ margin-bottom: 25px;
42
+ }
43
+ label {
44
+ display: block;
45
+ color: #555;
46
+ font-weight: 600;
47
+ margin-bottom: 8px;
48
+ }
49
+ input[type="text"] {
50
+ width: 100%;
51
+ padding: 12px 15px;
52
+ border: 2px solid #e0e0e0;
53
+ border-radius: 8px;
54
+ font-size: 15px;
55
+ transition: border-color 0.3s;
56
+ }
57
+ input[type="text"]:focus {
58
+ outline: none;
59
+ border-color: #667eea;
60
+ }
61
+ .radio-group {
62
+ display: flex;
63
+ gap: 20px;
64
+ margin-top: 10px;
65
+ }
66
+ .radio-item {
67
+ display: flex;
68
+ align-items: center;
69
+ gap: 8px;
70
+ }
71
+ input[type="radio"] {
72
+ width: 18px;
73
+ height: 18px;
74
+ cursor: pointer;
75
+ }
76
+ button {
77
+ width: 100%;
78
+ padding: 14px;
79
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
80
+ color: white;
81
+ border: none;
82
+ border-radius: 8px;
83
+ font-size: 16px;
84
+ font-weight: 600;
85
+ cursor: pointer;
86
+ transition: transform 0.2s, box-shadow 0.2s;
87
+ }
88
+ button:hover {
89
+ transform: translateY(-2px);
90
+ box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
91
+ }
92
+ button:disabled {
93
+ background: #ccc;
94
+ cursor: not-allowed;
95
+ transform: none;
96
+ }
97
+ .result {
98
+ margin-top: 25px;
99
+ padding: 20px;
100
+ border-radius: 8px;
101
+ display: none;
102
+ }
103
+ .result.success {
104
+ background: #d4edda;
105
+ border: 1px solid #c3e6cb;
106
+ color: #155724;
107
+ }
108
+ .result.error {
109
+ background: #f8d7da;
110
+ border: 1px solid #f5c6cb;
111
+ color: #721c24;
112
+ }
113
+ .download-btn {
114
+ margin-top: 15px;
115
+ background: #28a745;
116
+ display: inline-block;
117
+ padding: 10px 20px;
118
+ text-decoration: none;
119
+ border-radius: 5px;
120
+ color: white;
121
+ font-weight: 600;
122
+ }
123
+ .loader {
124
+ display: none;
125
+ text-align: center;
126
+ margin-top: 20px;
127
+ }
128
+ .spinner {
129
+ border: 4px solid #f3f3f3;
130
+ border-top: 4px solid #667eea;
131
+ border-radius: 50%;
132
+ width: 40px;
133
+ height: 40px;
134
+ animation: spin 1s linear infinite;
135
+ margin: 0 auto;
136
+ }
137
+ @keyframes spin {
138
+ 0% { transform: rotate(0deg); }
139
+ 100% { transform: rotate(360deg); }
140
+ }
141
+ </style>
142
+ </head>
143
+ <body>
144
+ <div class="container">
145
+ <h1>🔍 Web Scraper Tool</h1>
146
+ <p class="subtitle">Extract data from websites and download as Excel</p>
147
+
148
+ <form id="scraperForm">
149
+ <div class="form-group">
150
+ <label for="url">Website URL</label>
151
+ <input
152
+ type="text"
153
+ id="url"
154
+ name="url"
155
+ placeholder="https://example.com"
156
+ required
157
+ >
158
+ </div>
159
+
160
+ <div class="form-group">
161
+ <label>What to Extract?</label>
162
+ <div class="radio-group">
163
+ <div class="radio-item">
164
+ <input type="radio" id="table" name="mode" value="table" checked>
165
+ <label for="table">Tables</label>
166
+ </div>
167
+ <div class="radio-item">
168
+ <input type="radio" id="links" name="mode" value="links">
169
+ <label for="links">Links</label>
170
+ </div>
171
+ </div>
172
+ </div>
173
+
174
+ <button type="submit" id="submitBtn">Extract Data</button>
175
+ </form>
176
+
177
+ <div class="loader" id="loader">
178
+ <div class="spinner"></div>
179
+ <p>Extracting data...</p>
180
+ </div>
181
+
182
+ <div class="result" id="result"></div>
183
+ </div>
184
+
185
+ <script>
186
+ document.getElementById('scraperForm').addEventListener('submit', async (e) => {
187
+ e.preventDefault();
188
+
189
+ const url = document.getElementById('url').value;
190
+ const mode = document.querySelector('input[name="mode"]:checked').value;
191
+ const submitBtn = document.getElementById('submitBtn');
192
+ const loader = document.getElementById('loader');
193
+ const result = document.getElementById('result');
194
+
195
+ // Reset result
196
+ result.style.display = 'none';
197
+ result.className = 'result';
198
+
199
+ // Show loader
200
+ submitBtn.disabled = true;
201
+ loader.style.display = 'block';
202
+
203
+ try {
204
+ const response = await fetch('/scrape', {
205
+ method: 'POST',
206
+ headers: {
207
+ 'Content-Type': 'application/json',
208
+ },
209
+ body: JSON.stringify({ url, mode })
210
+ });
211
+
212
+ if (!response.ok) {
213
+ throw new Error('Failed to extract data');
214
+ }
215
+
216
+ // Get the blob
217
+ const blob = await response.blob();
218
+
219
+ // Create download link
220
+ const downloadUrl = window.URL.createObjectURL(blob);
221
+ const a = document.createElement('a');
222
+ a.href = downloadUrl;
223
+ a.download = 'scraped_data.xlsx';
224
+ document.body.appendChild(a);
225
+ a.click();
226
+ window.URL.revokeObjectURL(downloadUrl);
227
+ document.body.removeChild(a);
228
+
229
+ // Show success message
230
+ result.className = 'result success';
231
+ result.innerHTML = '✅ Data extracted successfully! Your download should start automatically.';
232
+ result.style.display = 'block';
233
+
234
+ } catch (error) {
235
+ result.className = 'result error';
236
+ result.innerHTML = `❌ Error: ${error.message}. Please check the URL and try again.`;
237
+ result.style.display = 'block';
238
+ } finally {
239
+ submitBtn.disabled = false;
240
+ loader.style.display = 'none';
241
+ }
242
+ });
243
+ </script>
244
+ </body>
245
+ </html>