Spaces:
Sleeping
Sleeping
Upload src/streamlit_app.py with huggingface_hub
Browse files- src/streamlit_app.py +553 -40
src/streamlit_app.py
CHANGED
@@ -1,40 +1,553 @@
|
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AI Research Assistant Interface
|
2 |
+
|
3 |
+
Based on your requirements, I'll create a clean, responsive web interface for an AI research assistant that specializes in web research and content extraction.
|
4 |
+
|
5 |
+
=== index.html ===
|
6 |
+
<!DOCTYPE html>
|
7 |
+
<html lang="pl">
|
8 |
+
<head>
|
9 |
+
<meta charset="UTF-8">
|
10 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
11 |
+
<meta name="description" content="Zaawansowany Asystent AI do bada艅 internetowych i ekstrakcji tre艣ci">
|
12 |
+
<meta name="keywords" content="AI, research, web scraping, content extraction, data saving">
|
13 |
+
<title>AI Research Assistant</title>
|
14 |
+
<link rel="stylesheet" href="assets/css/styles.css">
|
15 |
+
</head>
|
16 |
+
<body>
|
17 |
+
<header>
|
18 |
+
<div class="container">
|
19 |
+
<h1>AI Research Assistant</h1>
|
20 |
+
<p>Zaawansowany asystent do bada艅 internetowych i ekstrakcji tre艣ci</p>
|
21 |
+
</div>
|
22 |
+
</header>
|
23 |
+
|
24 |
+
<main class="container">
|
25 |
+
<section class="intro">
|
26 |
+
<h2>Jak mog臋 Ci pom贸c?</h2>
|
27 |
+
<p>Jestem specjalist膮 w badaniach internetowych i ekstrakcji tre艣ci. Wybierz jedn膮 z poni偶szych opcji:</p>
|
28 |
+
</section>
|
29 |
+
|
30 |
+
<div class="tabs">
|
31 |
+
<div class="tab-buttons">
|
32 |
+
<button class="tab-button active" data-tab="search">Wyszukiwanie WWW</button>
|
33 |
+
<button class="tab-button" data-tab="scrape">Scrapowanie strony</button>
|
34 |
+
<button class="tab-button" data-tab="save">Zapisywanie plik贸w</button>
|
35 |
+
</div>
|
36 |
+
|
37 |
+
<div class="tab-content">
|
38 |
+
<div id="search-tab" class="tab-pane active">
|
39 |
+
<h3>Wyszukiwanie informacji w internecie</h3>
|
40 |
+
<p>Wprowad藕 zapytanie, a przeszukam internet w poszukiwaniu odpowiedzi.</p>
|
41 |
+
<form id="search-form">
|
42 |
+
<div class="form-group">
|
43 |
+
<label for="search-query">Twoje zapytanie:</label>
|
44 |
+
<input type="text" id="search-query" placeholder="Wprowad藕 temat wyszukiwania..." required>
|
45 |
+
</div>
|
46 |
+
<button type="submit" class="btn-primary">Wyszukaj</button>
|
47 |
+
</form>
|
48 |
+
<div id="search-results" class="results-container hidden"></div>
|
49 |
+
</div>
|
50 |
+
|
51 |
+
<div id="scrape-tab" class="tab-pane">
|
52 |
+
<h3>Pobieranie tre艣ci ze strony</h3>
|
53 |
+
<p>Podaj adres URL, a pobior臋 i wyczy艣c臋 tre艣膰 ze wskazanej strony.</p>
|
54 |
+
<form id="scrape-form">
|
55 |
+
<div class="form-group">
|
56 |
+
<label for="scrape-url">Adres URL:</label>
|
57 |
+
<input type="url" id="scrape-url" placeholder="https://przyklad.com/artykul" required>
|
58 |
+
</div>
|
59 |
+
<button type="submit" class="btn-primary">Pobierz tre艣膰</button>
|
60 |
+
</form>
|
61 |
+
<div id="scrape-results" class="results-container hidden"></div>
|
62 |
+
</div>
|
63 |
+
|
64 |
+
<div id="save-tab" class="tab-pane">
|
65 |
+
<h3>Zapisywanie tre艣ci do pliku</h3>
|
66 |
+
<p>Wybierz format i zapisz pobrane tre艣ci.</p>
|
67 |
+
<form id="save-form">
|
68 |
+
<div class="form-group">
|
69 |
+
<label for="save-content">Tre艣膰 do zapisania:</label>
|
70 |
+
<textarea id="save-content" rows="6" placeholder="Wklej tutaj tre艣膰 do zapisania..." required></textarea>
|
71 |
+
</div>
|
72 |
+
<div class="form-group">
|
73 |
+
<label for="format-select">Wybierz format:</label>
|
74 |
+
<select id="format-select">
|
75 |
+
<option value="md">Markdown (.md)</option>
|
76 |
+
<option value="json">JSON (.json)</option>
|
77 |
+
<option value="pdf">PDF (.pdf)</option>
|
78 |
+
</select>
|
79 |
+
</div>
|
80 |
+
<div class="form-group">
|
81 |
+
<label for="filename">Nazwa pliku:</label>
|
82 |
+
<input type="text" id="filename" placeholder="nazwa-pliku" required>
|
83 |
+
</div>
|
84 |
+
<button type="submit" class="btn-primary">Zapisz plik</button>
|
85 |
+
</form>
|
86 |
+
<div id="save-results" class="results-container hidden"></div>
|
87 |
+
</div>
|
88 |
+
</div>
|
89 |
+
</div>
|
90 |
+
|
91 |
+
<section class="features">
|
92 |
+
<h2>Moje narz臋dzia</h2>
|
93 |
+
<div class="feature-grid">
|
94 |
+
<div class="feature-card">
|
95 |
+
<h3>Wyszukiwanie WWW</h3>
|
96 |
+
<p>Przeszukuj臋 internet na podstawie Twoich zapyta艅, priorytetyzuj膮c wiarygodne 藕r贸d艂a.</p>
|
97 |
+
</div>
|
98 |
+
<div class="feature-card">
|
99 |
+
<h3>Scrapowanie tre艣ci</h3>
|
100 |
+
<p>Pobieram i czyszcz臋 tre艣ci ze stron, usuwaj膮c reklamy, menu i elementy powtarzalne.</p>
|
101 |
+
</div>
|
102 |
+
<div class="feature-card">
|
103 |
+
<h3>Zapisywanie plik贸w</h3>
|
104 |
+
<p>Zapisuj臋 tre艣ci w wybranych formatach: Markdown, JSON lub PDF.</p>
|
105 |
+
</div>
|
106 |
+
</div>
|
107 |
+
</section>
|
108 |
+
</main>
|
109 |
+
|
110 |
+
<footer>
|
111 |
+
<div class="container">
|
112 |
+
<p>Zaawansowany Asystent AI © 2023. Wszystkie prawa zastrze偶one.</p>
|
113 |
+
</div>
|
114 |
+
</footer>
|
115 |
+
|
116 |
+
<script src="assets/js/script.js"></script>
|
117 |
+
</body>
|
118 |
+
</html>
|
119 |
+
|
120 |
+
=== assets/css/styles.css ===
|
121 |
+
/* Reset i podstawowe style */
|
122 |
+
* {
|
123 |
+
margin: 0;
|
124 |
+
padding: 0;
|
125 |
+
box-sizing: border-box;
|
126 |
+
}
|
127 |
+
|
128 |
+
body {
|
129 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
130 |
+
line-height: 1.6;
|
131 |
+
color: #333;
|
132 |
+
background-color: #f8f9fa;
|
133 |
+
}
|
134 |
+
|
135 |
+
.container {
|
136 |
+
width: 100%;
|
137 |
+
max-width: 1200px;
|
138 |
+
margin: 0 auto;
|
139 |
+
padding: 0 20px;
|
140 |
+
}
|
141 |
+
|
142 |
+
/* Nag艂贸wek */
|
143 |
+
header {
|
144 |
+
background: linear-gradient(135deg, #4a6fa5, #2a4e6c);
|
145 |
+
color: white;
|
146 |
+
padding: 2rem 0;
|
147 |
+
text-align: center;
|
148 |
+
margin-bottom: 2rem;
|
149 |
+
}
|
150 |
+
|
151 |
+
header h1 {
|
152 |
+
font-size: 2.5rem;
|
153 |
+
margin-bottom: 0.5rem;
|
154 |
+
}
|
155 |
+
|
156 |
+
header p {
|
157 |
+
font-size: 1.1rem;
|
158 |
+
opacity: 0.9;
|
159 |
+
}
|
160 |
+
|
161 |
+
/* Sekcja wprowadzenia */
|
162 |
+
.intro {
|
163 |
+
text-align: center;
|
164 |
+
margin-bottom: 2rem;
|
165 |
+
}
|
166 |
+
|
167 |
+
.intro h2 {
|
168 |
+
font-size: 2rem;
|
169 |
+
margin-bottom: 1rem;
|
170 |
+
color: #2a4e6c;
|
171 |
+
}
|
172 |
+
|
173 |
+
/* Zak艂adki */
|
174 |
+
.tabs {
|
175 |
+
background: white;
|
176 |
+
border-radius: 8px;
|
177 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
178 |
+
overflow: hidden;
|
179 |
+
margin-bottom: 3rem;
|
180 |
+
}
|
181 |
+
|
182 |
+
.tab-buttons {
|
183 |
+
display: flex;
|
184 |
+
border-bottom: 1px solid #e9ecef;
|
185 |
+
}
|
186 |
+
|
187 |
+
.tab-button {
|
188 |
+
padding: 1rem 1.5rem;
|
189 |
+
background: none;
|
190 |
+
border: none;
|
191 |
+
cursor: pointer;
|
192 |
+
font-size: 1rem;
|
193 |
+
font-weight: 500;
|
194 |
+
color: #6c757d;
|
195 |
+
transition: all 0.3s ease;
|
196 |
+
}
|
197 |
+
|
198 |
+
.tab-button:hover {
|
199 |
+
background-color: #f8f9fa;
|
200 |
+
color: #4a6fa5;
|
201 |
+
}
|
202 |
+
|
203 |
+
.tab-button.active {
|
204 |
+
color: #4a6fa5;
|
205 |
+
border-bottom: 3px solid #4a6fa5;
|
206 |
+
}
|
207 |
+
|
208 |
+
.tab-content {
|
209 |
+
padding: 2rem;
|
210 |
+
}
|
211 |
+
|
212 |
+
.tab-pane {
|
213 |
+
display: none;
|
214 |
+
}
|
215 |
+
|
216 |
+
.tab-pane.active {
|
217 |
+
display: block;
|
218 |
+
}
|
219 |
+
|
220 |
+
/* Formularze */
|
221 |
+
.form-group {
|
222 |
+
margin-bottom: 1.5rem;
|
223 |
+
}
|
224 |
+
|
225 |
+
label {
|
226 |
+
display: block;
|
227 |
+
margin-bottom: 0.5rem;
|
228 |
+
font-weight: 500;
|
229 |
+
}
|
230 |
+
|
231 |
+
input[type="text"],
|
232 |
+
input[type="url"],
|
233 |
+
textarea,
|
234 |
+
select {
|
235 |
+
width: 100%;
|
236 |
+
padding: 0.75rem;
|
237 |
+
border: 1px solid #ced4da;
|
238 |
+
border-radius: 4px;
|
239 |
+
font-size: 1rem;
|
240 |
+
transition: border-color 0.3s;
|
241 |
+
}
|
242 |
+
|
243 |
+
input[type="text"]:focus,
|
244 |
+
input[type="url"]:focus,
|
245 |
+
textarea:focus,
|
246 |
+
select:focus {
|
247 |
+
outline: none;
|
248 |
+
border-color: #4a6fa5;
|
249 |
+
box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.25);
|
250 |
+
}
|
251 |
+
|
252 |
+
textarea {
|
253 |
+
resize: vertical;
|
254 |
+
min-height: 120px;
|
255 |
+
}
|
256 |
+
|
257 |
+
/* Przyciski */
|
258 |
+
.btn-primary {
|
259 |
+
background-color: #4a6fa5;
|
260 |
+
color: white;
|
261 |
+
border: none;
|
262 |
+
padding: 0.75rem 1.5rem;
|
263 |
+
border-radius: 4px;
|
264 |
+
font-size: 1rem;
|
265 |
+
cursor: pointer;
|
266 |
+
transition: background-color 0.3s;
|
267 |
+
}
|
268 |
+
|
269 |
+
.btn-primary:hover {
|
270 |
+
background-color: #3a5a80;
|
271 |
+
}
|
272 |
+
|
273 |
+
/* Wyniki */
|
274 |
+
.results-container {
|
275 |
+
margin-top: 2rem;
|
276 |
+
padding: 1.5rem;
|
277 |
+
background-color: #f8f9fa;
|
278 |
+
border-radius: 4px;
|
279 |
+
border-left: 4px solid #4a6fa5;
|
280 |
+
}
|
281 |
+
|
282 |
+
.hidden {
|
283 |
+
display: none;
|
284 |
+
}
|
285 |
+
|
286 |
+
.result-item {
|
287 |
+
margin-bottom: 1rem;
|
288 |
+
padding-bottom: 1rem;
|
289 |
+
border-bottom: 1px solid #e9ecef;
|
290 |
+
}
|
291 |
+
|
292 |
+
.result-item:last-child {
|
293 |
+
border-bottom: none;
|
294 |
+
margin-bottom: 0;
|
295 |
+
padding-bottom: 0;
|
296 |
+
}
|
297 |
+
|
298 |
+
.result-title {
|
299 |
+
font-weight: 600;
|
300 |
+
color: #2a4e6c;
|
301 |
+
margin-bottom: 0.25rem;
|
302 |
+
}
|
303 |
+
|
304 |
+
.result-url {
|
305 |
+
color: #6c757d;
|
306 |
+
font-size: 0.9rem;
|
307 |
+
margin-bottom: 0.5rem;
|
308 |
+
}
|
309 |
+
|
310 |
+
.result-description {
|
311 |
+
margin-bottom: 0.5rem;
|
312 |
+
}
|
313 |
+
|
314 |
+
/* Sekcja funkcji */
|
315 |
+
.features {
|
316 |
+
margin-bottom: 3rem;
|
317 |
+
}
|
318 |
+
|
319 |
+
.features h2 {
|
320 |
+
text-align: center;
|
321 |
+
font-size: 2rem;
|
322 |
+
margin-bottom: 2rem;
|
323 |
+
color: #2a4e6c;
|
324 |
+
}
|
325 |
+
|
326 |
+
.feature-grid {
|
327 |
+
display: grid;
|
328 |
+
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
329 |
+
gap: 2rem;
|
330 |
+
}
|
331 |
+
|
332 |
+
.feature-card {
|
333 |
+
background: white;
|
334 |
+
padding: 2rem;
|
335 |
+
border-radius: 8px;
|
336 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
|
337 |
+
text-align: center;
|
338 |
+
transition: transform 0.3s ease;
|
339 |
+
}
|
340 |
+
|
341 |
+
.feature-card:hover {
|
342 |
+
transform: translateY(-5px);
|
343 |
+
}
|
344 |
+
|
345 |
+
.feature-card h3 {
|
346 |
+
color: #4a6fa5;
|
347 |
+
margin-bottom: 1rem;
|
348 |
+
}
|
349 |
+
|
350 |
+
/* Stopka */
|
351 |
+
footer {
|
352 |
+
background-color: #2a4e6c;
|
353 |
+
color: white;
|
354 |
+
text-align: center;
|
355 |
+
padding: 1.5rem 0;
|
356 |
+
margin-top: 3rem;
|
357 |
+
}
|
358 |
+
|
359 |
+
/* Responsywno艣膰 */
|
360 |
+
@media (max-width: 768px) {
|
361 |
+
.tab-buttons {
|
362 |
+
flex-direction: column;
|
363 |
+
}
|
364 |
+
|
365 |
+
.tab-button {
|
366 |
+
width: 100%;
|
367 |
+
text-align: center;
|
368 |
+
}
|
369 |
+
|
370 |
+
.feature-grid {
|
371 |
+
grid-template-columns: 1fr;
|
372 |
+
}
|
373 |
+
|
374 |
+
header h1 {
|
375 |
+
font-size: 2rem;
|
376 |
+
}
|
377 |
+
}
|
378 |
+
|
379 |
+
=== assets/js/script.js ===
|
380 |
+
document.addEventListener('DOMContentLoaded', function() {
|
381 |
+
// Obs艂uga zak艂adek
|
382 |
+
const tabButtons = document.querySelectorAll('.tab-button');
|
383 |
+
const tabPanes = document.querySelectorAll('.tab-pane');
|
384 |
+
|
385 |
+
tabButtons.forEach(button => {
|
386 |
+
button.addEventListener('click', () => {
|
387 |
+
const tabId = button.getAttribute('data-tab');
|
388 |
+
|
389 |
+
// Usu艅 aktywn膮 klas臋 ze wszystkich przycisk贸w i paneli
|
390 |
+
tabButtons.forEach(btn => btn.classList.remove('active'));
|
391 |
+
tabPanes.forEach(pane => pane.classList.remove('active'));
|
392 |
+
|
393 |
+
// Dodaj aktywn膮 klas臋 do klikni臋tego przycisku i odpowiedniego panelu
|
394 |
+
button.classList.add('active');
|
395 |
+
document.getElementById(`${tabId}-tab`).classList.add('active');
|
396 |
+
});
|
397 |
+
});
|
398 |
+
|
399 |
+
// Obs艂uga formularza wyszukiwania
|
400 |
+
const searchForm = document.getElementById('search-form');
|
401 |
+
const searchResults = document.getElementById('search-results');
|
402 |
+
|
403 |
+
searchForm.addEventListener('submit', function(e) {
|
404 |
+
e.preventDefault();
|
405 |
+
|
406 |
+
const query = document.getElementById('search-query').value.trim();
|
407 |
+
|
408 |
+
if (query) {
|
409 |
+
// Symulacja wyszukiwania (w rzeczywisto艣ci po艂膮czy艂oby si臋 z API)
|
410 |
+
simulateWebSearch(query);
|
411 |
+
}
|
412 |
+
});
|
413 |
+
|
414 |
+
// Obs艂uga formularza scrapowania
|
415 |
+
const scrapeForm = document.getElementById('scrape-form');
|
416 |
+
const scrapeResults = document.getElementById('scrape-results');
|
417 |
+
|
418 |
+
scrapeForm.addEventListener('submit', function(e) {
|
419 |
+
e.preventDefault();
|
420 |
+
|
421 |
+
const url = document.getElementById('scrape-url').value.trim();
|
422 |
+
|
423 |
+
if (url) {
|
424 |
+
// Symulacja scrapowania (w rzeczywisto艣ci po艂膮czy艂oby si臋 z API)
|
425 |
+
simulateWebScrape(url);
|
426 |
+
}
|
427 |
+
});
|
428 |
+
|
429 |
+
// Obs艂uga formularza zapisywania
|
430 |
+
const saveForm = document.getElementById('save-form');
|
431 |
+
const saveResults = document.getElementById('save-results');
|
432 |
+
|
433 |
+
saveForm.addEventListener('submit', function(e) {
|
434 |
+
e.preventDefault();
|
435 |
+
|
436 |
+
const content = document.getElementById('save-content').value.trim();
|
437 |
+
const format = document.getElementById('format-select').value;
|
438 |
+
const filename = document.getElementById('filename').value.trim();
|
439 |
+
|
440 |
+
if (content && filename) {
|
441 |
+
// Symulacja zapisywania (w rzeczywisto艣ci po艂膮czy艂oby si臋 z API)
|
442 |
+
simulateSaveFile(content, format, filename);
|
443 |
+
}
|
444 |
+
});
|
445 |
+
|
446 |
+
// Funkcje symuluj膮ce dzia艂anie API
|
447 |
+
function simulateWebSearch(query) {
|
448 |
+
searchResults.innerHTML = '<p class="loading">Wyszukiwanie... (symulacja)</p>';
|
449 |
+
searchResults.classList.remove('hidden');
|
450 |
+
|
451 |
+
// Symulacja op贸藕nienia zapytania
|
452 |
+
setTimeout(() => {
|
453 |
+
const results = [
|
454 |
+
{
|
455 |
+
title: 'Wynik wyszukiwania 1 dla: ' + query,
|
456 |
+
url: 'https://przyklad.com/wynik-1',
|
457 |
+
description: 'To jest przyk艂adowy opis wyniku wyszukiwania. Zawiera istotne informacje na temat zapytania.'
|
458 |
+
},
|
459 |
+
{
|
460 |
+
title: 'Wynik wyszukiwania 2 dla: ' + query,
|
461 |
+
url: 'https://przyklad.com/wynik-2',
|
462 |
+
description: 'Kolejny przyk艂adowy wynik wyszukiwania z odpowiednimi informacjami.'
|
463 |
+
},
|
464 |
+
{
|
465 |
+
title: 'Wynik wyszukiwania 3 dla: ' + query,
|
466 |
+
url: 'https://przyklad.com/wynik-3',
|
467 |
+
description: 'Trzeci przyk艂adowy wynik zawieraj膮cy warto艣ciowe tre艣ci zwi膮zane z zapytaniem.'
|
468 |
+
}
|
469 |
+
];
|
470 |
+
|
471 |
+
displaySearchResults(results);
|
472 |
+
}, 1500);
|
473 |
+
}
|
474 |
+
|
475 |
+
function displaySearchResults(results) {
|
476 |
+
let html = '<h3>Wyniki wyszukiwania:</h3>';
|
477 |
+
|
478 |
+
results.forEach(result => {
|
479 |
+
html += `
|
480 |
+
<div class="result-item">
|
481 |
+
<div class="result-title">${result.title}</div>
|
482 |
+
<div class="result-url">${result.url}</div>
|
483 |
+
<div class="result-description">${result.description}</div>
|
484 |
+
<button class="btn-primary scrape-from-result" data-url="${result.url}">Pobierz tre艣膰</button>
|
485 |
+
</div>
|
486 |
+
`;
|
487 |
+
});
|
488 |
+
|
489 |
+
searchResults.innerHTML = html;
|
490 |
+
|
491 |
+
// Dodanie obs艂ugi przycisk贸w do scrapowania z wynik贸w
|
492 |
+
document.querySelectorAll('.scrape-from-result').forEach(button => {
|
493 |
+
button.addEventListener('click', function() {
|
494 |
+
const url = this.getAttribute('data-url');
|
495 |
+
document.getElementById('scrape-url').value = url;
|
496 |
+
|
497 |
+
// Prze艂膮czenie na zak艂adk臋 scrapowania
|
498 |
+
document.querySelector('[data-tab="scrape"]').click();
|
499 |
+
|
500 |
+
// Automatyczne uruchomienie scrapowania
|
501 |
+
simulateWebScrape(url);
|
502 |
+
});
|
503 |
+
});
|
504 |
+
}
|
505 |
+
|
506 |
+
function simulateWebScrape(url) {
|
507 |
+
scrapeResults.innerHTML = '<p class="loading">Pobieranie tre艣ci... (symulacja)</p>';
|
508 |
+
scrapeResults.classList.remove('hidden');
|
509 |
+
|
510 |
+
// Symulacja op贸藕nienia scrapowania
|
511 |
+
setTimeout(() => {
|
512 |
+
const content = `
|
513 |
+
<h3>Przyk艂adowa tre艣膰 pobrana z: ${url}</h3>
|
514 |
+
<p>To jest symulowana tre艣膰 artyku艂u pobrana ze wskazanej strony internetowej. W rzeczywistym scenariuszu ta tre艣膰 zosta艂aby pobrana, wyczyszczona z element贸w takich jak reklamy, menu nawigacyjne i komentarze.</p>
|
515 |
+
<p>Tre艣膰 zosta艂a przetworzona w celu zachowania tylko istotnych informacji z artyku艂u, zgodnie z zasadami robots.txt i warunkami serwisu.</p>
|
516 |
+
<div class="actions">
|
517 |
+
<button class="btn-primary save-scraped-content" data-content="Przyk艂adowa tre艣膰 pobrana z: ${url}">Zapisz t臋 tre艣膰</button>
|
518 |
+
</div>
|
519 |
+
`;
|
520 |
+
|
521 |
+
scrapeResults.innerHTML = content;
|
522 |
+
|
523 |
+
// Dodanie obs艂ugi przycisku zapisywania
|
524 |
+
document.querySelector('.save-scraped-content').addEventListener('click', function() {
|
525 |
+
const content = this.getAttribute('data-content');
|
526 |
+
document.getElementById('save-content').value = content;
|
527 |
+
|
528 |
+
// Prze艂膮czenie na zak艂adk臋 zapisywania
|
529 |
+
document.querySelector('[data-tab="save"]').click();
|
530 |
+
});
|
531 |
+
}, 2000);
|
532 |
+
}
|
533 |
+
|
534 |
+
function simulateSaveFile(content, format, filename) {
|
535 |
+
saveResults.innerHTML = '<p class="loading">Zapisywanie pliku... (symulacja)</p>';
|
536 |
+
saveResults.classList.remove('hidden');
|
537 |
+
|
538 |
+
// Symulacja op贸藕nienia zapisywania
|
539 |
+
setTimeout(() => {
|
540 |
+
const fullFilename = `${filename}.${format}`;
|
541 |
+
saveResults.innerHTML = `
|
542 |
+
<div class="success-message">
|
543 |
+
<h3>Plik zosta艂 zapisany!</h3>
|
544 |
+
<p>Tre艣膰 zosta艂a pomy艣lnie zapisana jako <strong>${fullFilename}</strong></p>
|
545 |
+
<p>W rzeczywistym scenariuszu plik zosta艂by pobrany na Tw贸j komputer.</p>
|
546 |
+
</div>
|
547 |
+
`;
|
548 |
+
|
549 |
+
// Reset formularza
|
550 |
+
document.getElementById('save-form').reset();
|
551 |
+
}, 1500);
|
552 |
+
}
|
553 |
+
});
|