Intimafit commited on
Commit
b3388d8
路
verified 路
1 Parent(s): d05a344

Add 3 files

Browse files
Files changed (3) hide show
  1. README.md +6 -4
  2. index.html +338 -19
  3. prompts.txt +2 -0
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Extraer Codigos Html Css Js
3
- emoji: 馃
4
- colorFrom: gray
5
  colorTo: red
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: extraer-codigos-html-css-js
3
+ emoji: 馃惓
4
+ colorFrom: blue
5
  colorTo: red
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,338 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="es">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Extractor de C贸digo Fuente Web</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ .gradient-bg {
11
+ background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
12
+ }
13
+ .code-container {
14
+ max-height: 500px;
15
+ overflow-y: auto;
16
+ background-color: #1e293b;
17
+ color: #f8fafc;
18
+ font-family: 'Courier New', monospace;
19
+ border-radius: 0.5rem;
20
+ }
21
+ pre {
22
+ white-space: pre-wrap;
23
+ word-wrap: break-word;
24
+ padding: 1rem;
25
+ margin: 0;
26
+ }
27
+ .tab-button {
28
+ transition: all 0.2s ease;
29
+ }
30
+ .tab-button.active {
31
+ background-color: #4f46e5;
32
+ color: white;
33
+ }
34
+ .download-btn {
35
+ transition: all 0.2s ease;
36
+ }
37
+ .download-btn:hover {
38
+ transform: translateY(-2px);
39
+ }
40
+ </style>
41
+ </head>
42
+ <body class="bg-gray-100 min-h-screen">
43
+ <div class="container mx-auto px-4 py-8">
44
+ <div class="text-center mb-12">
45
+ <h1 class="text-4xl font-bold text-gray-800 mb-4">Extractor de C贸digo Fuente Web</h1>
46
+ <p class="text-xl text-gray-600 max-w-2xl mx-auto">
47
+ Obt茅n el c贸digo HTML, CSS y JavaScript de cualquier p谩gina web ingresando su URL
48
+ </p>
49
+ </div>
50
+
51
+ <div class="max-w-4xl mx-auto bg-white rounded-xl shadow-lg overflow-hidden">
52
+ <div class="p-6 gradient-bg text-white">
53
+ <div class="flex flex-col md:flex-row md:items-center gap-4">
54
+ <input
55
+ type="url"
56
+ id="url-input"
57
+ placeholder="https://ejemplo.com"
58
+ class="flex-grow px-4 py-3 rounded-lg text-gray-800 focus:outline-none focus:ring-2 focus:ring-purple-300"
59
+ required
60
+ >
61
+ <button
62
+ id="fetch-btn"
63
+ class="px-6 py-3 bg-white text-purple-600 font-bold rounded-lg hover:bg-gray-100 transition flex items-center justify-center"
64
+ >
65
+ <i class="fas fa-code mr-2"></i> Extraer C贸digo
66
+ </button>
67
+ </div>
68
+ </div>
69
+
70
+ <div class="p-6">
71
+ <div class="flex border-b border-gray-200 mb-4">
72
+ <button class="tab-button px-4 py-2 rounded-t-lg active" data-tab="html">HTML</button>
73
+ <button class="tab-button px-4 py-2 rounded-t-lg" data-tab="css">CSS</button>
74
+ <button class="tab-button px-4 py-2 rounded-t-lg" data-tab="js">JavaScript</button>
75
+ <button class="tab-button px-4 py-2 rounded-t-lg" data-tab="all">Todo</button>
76
+ </div>
77
+
78
+ <div id="loading" class="text-center py-12 hidden">
79
+ <div class="animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-purple-500 mx-auto mb-4"></div>
80
+ <p class="text-gray-600">Analizando la p谩gina web...</p>
81
+ </div>
82
+
83
+ <div id="error-message" class="hidden bg-red-100 border-l-4 border-red-500 text-red-700 p-4 mb-4 rounded">
84
+ <p id="error-text"></p>
85
+ </div>
86
+
87
+ <div id="results" class="hidden">
88
+ <div class="flex justify-between items-center mb-4">
89
+ <h3 class="text-lg font-semibold text-gray-800" id="current-tab-title">HTML</h3>
90
+ <button
91
+ id="download-btn"
92
+ class="download-btn px-4 py-2 bg-purple-600 text-white rounded-lg hover:bg-purple-700 flex items-center"
93
+ >
94
+ <i class="fas fa-download mr-2"></i> Descargar
95
+ </button>
96
+ </div>
97
+
98
+ <div class="code-container">
99
+ <pre id="html-code"></pre>
100
+ <pre id="css-code" class="hidden"></pre>
101
+ <pre id="js-code" class="hidden"></pre>
102
+ <pre id="all-code" class="hidden"></pre>
103
+ </div>
104
+ </div>
105
+
106
+ <div id="instructions" class="bg-blue-50 border-l-4 border-blue-500 text-blue-700 p-4 rounded">
107
+ <p class="font-semibold">Instrucciones:</p>
108
+ <ol class="list-decimal pl-5 mt-2 space-y-1">
109
+ <li>Ingresa la URL completa (incluyendo https://)</li>
110
+ <li>Haz clic en "Extraer C贸digo"</li>
111
+ <li>Navega entre las pesta帽as para ver HTML, CSS o JS</li>
112
+ <li>Descarga el c贸digo que necesites</li>
113
+ </ol>
114
+ </div>
115
+ </div>
116
+ </div>
117
+
118
+ <div class="max-w-4xl mx-auto mt-8 bg-white rounded-xl shadow-lg overflow-hidden">
119
+ <div class="p-6">
120
+ <h2 class="text-xl font-semibold text-gray-800 mb-4">驴C贸mo funciona?</h2>
121
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
122
+ <div class="bg-gray-50 p-4 rounded-lg">
123
+ <div class="w-12 h-12 gradient-bg rounded-full flex items-center justify-center text-white text-xl mb-3">
124
+ <i class="fas fa-globe"></i>
125
+ </div>
126
+ <h3 class="font-semibold text-gray-800 mb-2">1. Solicitud HTTP</h3>
127
+ <p class="text-gray-600 text-sm">Hacemos una solicitud a la URL proporcionada para obtener el contenido HTML.</p>
128
+ </div>
129
+ <div class="bg-gray-50 p-4 rounded-lg">
130
+ <div class="w-12 h-12 gradient-bg rounded-full flex items-center justify-center text-white text-xl mb-3">
131
+ <i class="fas fa-code"></i>
132
+ </div>
133
+ <h3 class="font-semibold text-gray-800 mb-2">2. An谩lisis del C贸digo</h3>
134
+ <p class="text-gray-600 text-sm">Extraemos y separamos el HTML, CSS y JavaScript del c贸digo fuente.</p>
135
+ </div>
136
+ <div class="bg-gray-50 p-4 rounded-lg">
137
+ <div class="w-12 h-12 gradient-bg rounded-full flex items-center justify-center text-white text-xl mb-3">
138
+ <i class="fas fa-file-download"></i>
139
+ </div>
140
+ <h3 class="font-semibold text-gray-800 mb-2">3. Descarga</h3>
141
+ <p class="text-gray-600 text-sm">Puedes descargar cada parte del c贸digo por separado o todo junto.</p>
142
+ </div>
143
+ </div>
144
+ </div>
145
+ </div>
146
+ </div>
147
+
148
+ <footer class="bg-gray-800 text-gray-400 py-8 mt-12">
149
+ <div class="container mx-auto px-4 text-center">
150
+ <p>漏 2023 Extractor de C贸digo Web. Todos los derechos reservados.</p>
151
+ </div>
152
+ </footer>
153
+
154
+ <script>
155
+ document.addEventListener('DOMContentLoaded', function() {
156
+ const urlInput = document.getElementById('url-input');
157
+ const fetchBtn = document.getElementById('fetch-btn');
158
+ const loading = document.getElementById('loading');
159
+ const results = document.getElementById('results');
160
+ const errorMessage = document.getElementById('error-message');
161
+ const errorText = document.getElementById('error-text');
162
+ const instructions = document.getElementById('instructions');
163
+ const downloadBtn = document.getElementById('download-btn');
164
+ const tabButtons = document.querySelectorAll('.tab-button');
165
+ const htmlCode = document.getElementById('html-code');
166
+ const cssCode = document.getElementById('css-code');
167
+ const jsCode = document.getElementById('js-code');
168
+ const allCode = document.getElementById('all-code');
169
+ const currentTabTitle = document.getElementById('current-tab-title');
170
+
171
+ let currentTab = 'html';
172
+ let sourceData = {
173
+ html: '',
174
+ css: '',
175
+ js: ''
176
+ };
177
+
178
+ // Manejar clic en las pesta帽as
179
+ tabButtons.forEach(button => {
180
+ button.addEventListener('click', function() {
181
+ // Actualizar pesta帽a activa
182
+ tabButtons.forEach(btn => btn.classList.remove('active'));
183
+ this.classList.add('active');
184
+ currentTab = this.dataset.tab;
185
+
186
+ // Actualizar t铆tulo
187
+ let tabName = '';
188
+ switch(currentTab) {
189
+ case 'html': tabName = 'HTML'; break;
190
+ case 'css': tabName = 'CSS'; break;
191
+ case 'js': tabName = 'JavaScript'; break;
192
+ case 'all': tabName = 'Todo el c贸digo'; break;
193
+ }
194
+ currentTabTitle.textContent = tabName;
195
+
196
+ // Mostrar el c贸digo correspondiente
197
+ document.querySelectorAll('.code-container pre').forEach(pre => pre.classList.add('hidden'));
198
+ document.getElementById(`${currentTab}-code`).classList.remove('hidden');
199
+ });
200
+ });
201
+
202
+ // Manejar clic en el bot贸n de extraer c贸digo
203
+ fetchBtn.addEventListener('click', async function() {
204
+ const url = urlInput.value.trim();
205
+
206
+ if (!url) {
207
+ showError('Por favor ingresa una URL v谩lida');
208
+ return;
209
+ }
210
+
211
+ try {
212
+ // Mostrar carga y ocultar otros elementos
213
+ loading.classList.remove('hidden');
214
+ results.classList.add('hidden');
215
+ errorMessage.classList.add('hidden');
216
+ instructions.classList.add('hidden');
217
+
218
+ // Usar un proxy CORS para evitar problemas de same-origin
219
+ const proxyUrl = `https://api.allorigins.win/get?url=${encodeURIComponent(url)}`;
220
+ const response = await fetch(proxyUrl);
221
+
222
+ if (!response.ok) {
223
+ throw new Error('No se pudo obtener el c贸digo fuente');
224
+ }
225
+
226
+ const data = await response.json();
227
+
228
+ if (data.contents) {
229
+ // Extraer HTML
230
+ sourceData.html = data.contents;
231
+
232
+ // Extraer CSS (simplificado - en una app real usar铆amos un parser m谩s sofisticado)
233
+ const styleTags = data.contents.match(/<style[^>]*>([\s\S]*?)<\/style>/gi) || [];
234
+ const linkTags = data.contents.match(/<link[^>]*rel=["']stylesheet["'][^>]*>/gi) || [];
235
+
236
+ let cssContent = styleTags.map(tag => {
237
+ return tag.replace(/<style[^>]*>([\s\S]*?)<\/style>/i, '$1');
238
+ }).join('\n\n');
239
+
240
+ sourceData.css = cssContent;
241
+
242
+ // Extraer JavaScript (simplificado)
243
+ const scriptTags = data.contents.match(/<script\b[^>]*>([\s\S]*?)<\/script>/gi) || [];
244
+
245
+ let jsContent = scriptTags.map(tag => {
246
+ // Ignorar scripts con src
247
+ if (tag.includes('src=')) return '';
248
+ return tag.replace(/<script\b[^>]*>([\s\S]*?)<\/script>/i, '$1');
249
+ }).join('\n\n');
250
+
251
+ sourceData.js = jsContent;
252
+
253
+ // Combinar todo el c贸digo
254
+ sourceData.all = `<!-- HTML -->\n${sourceData.html}\n\n<!-- CSS -->\n${sourceData.css}\n\n<!-- JavaScript -->\n${sourceData.js}`;
255
+
256
+ // Mostrar los resultados
257
+ htmlCode.textContent = sourceData.html;
258
+ cssCode.textContent = sourceData.css;
259
+ jsCode.textContent = sourceData.js;
260
+ allCode.textContent = sourceData.all;
261
+
262
+ loading.classList.add('hidden');
263
+ results.classList.remove('hidden');
264
+ } else {
265
+ throw new Error('No se pudo obtener el contenido de la p谩gina');
266
+ }
267
+ } catch (error) {
268
+ console.error('Error:', error);
269
+ showError(`Error al obtener el c贸digo: ${error.message}`);
270
+ loading.classList.add('hidden');
271
+ }
272
+ });
273
+
274
+ // Manejar clic en el bot贸n de descarga
275
+ downloadBtn.addEventListener('click', function() {
276
+ if (!sourceData.html) {
277
+ showError('No hay c贸digo para descargar');
278
+ return;
279
+ }
280
+
281
+ let content, extension;
282
+
283
+ switch(currentTab) {
284
+ case 'html':
285
+ content = sourceData.html;
286
+ extension = 'html';
287
+ break;
288
+ case 'css':
289
+ content = sourceData.css;
290
+ extension = 'css';
291
+ break;
292
+ case 'js':
293
+ content = sourceData.js;
294
+ extension = 'js';
295
+ break;
296
+ case 'all':
297
+ content = sourceData.all;
298
+ extension = 'txt';
299
+ break;
300
+ }
301
+
302
+ if (!content.trim()) {
303
+ showError(`No se encontr贸 c贸digo ${currentTab.toUpperCase()} para descargar`);
304
+ return;
305
+ }
306
+
307
+ downloadFile(content, `codigo-${currentTab}.${extension}`);
308
+ });
309
+
310
+ // Funci贸n para mostrar errores
311
+ function showError(message) {
312
+ errorText.textContent = message;
313
+ errorMessage.classList.remove('hidden');
314
+ setTimeout(() => {
315
+ errorMessage.classList.add('hidden');
316
+ }, 5000);
317
+ }
318
+
319
+ // Funci贸n para descargar archivo
320
+ function downloadFile(content, filename) {
321
+ const blob = new Blob([content], { type: 'text/plain' });
322
+ const url = URL.createObjectURL(blob);
323
+
324
+ const a = document.createElement('a');
325
+ a.href = url;
326
+ a.download = filename;
327
+ document.body.appendChild(a);
328
+ a.click();
329
+
330
+ setTimeout(() => {
331
+ document.body.removeChild(a);
332
+ URL.revokeObjectURL(url);
333
+ }, 100);
334
+ }
335
+ });
336
+ </script>
337
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 馃К <a href="https://enzostvs-deepsite.hf.space?remix=Intimafit/extraer-codigos-html-css-js" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
338
+ </html>
prompts.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ GENERAR HTML DE UNA WEB CON LA URL
2
+ IDENTIFICAR CODIGO HTML, CSS Y JS, DE UNA WEB AL SUMINISTRAR LA URL, GENERAR UNA OpCION pARA DESCARGAR ARCHIVO