File size: 13,034 Bytes
246cb17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CyberScraper 2077 API Documentation</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
            line-height: 1.6;
            color: #333;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 20px;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: white;
            border-radius: 12px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.2);
            overflow: hidden;
        }
        header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 40px;
            text-align: center;
        }
        header h1 {
            font-size: 2.5em;
            margin-bottom: 10px;
        }
        header p {
            font-size: 1.2em;
            opacity: 0.9;
        }
        .version {
            display: inline-block;
            background: rgba(255,255,255,0.2);
            padding: 5px 15px;
            border-radius: 20px;
            margin-top: 15px;
            font-size: 0.9em;
        }
        .content {
            padding: 40px;
        }
        .section {
            margin-bottom: 40px;
        }
        .section h2 {
            color: #667eea;
            border-bottom: 3px solid #667eea;
            padding-bottom: 10px;
            margin-bottom: 20px;
            font-size: 1.8em;
        }
        .endpoint {
            background: #f8f9fa;
            border-left: 4px solid #667eea;
            padding: 20px;
            margin-bottom: 20px;
            border-radius: 0 8px 8px 0;
        }
        .endpoint-header {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
            flex-wrap: wrap;
            gap: 10px;
        }
        .method {
            display: inline-block;
            padding: 5px 12px;
            border-radius: 5px;
            font-weight: bold;
            font-size: 0.9em;
            min-width: 80px;
            text-align: center;
        }
        .method.get { background: #61affe; color: white; }
        .method.post { background: #49cc90; color: white; }
        .method.delete { background: #f93e3e; color: white; }
        .path {
            font-family: 'Courier New', monospace;
            font-size: 1.1em;
            color: #333;
            font-weight: 600;
        }
        .description {
            color: #666;
            margin-bottom: 15px;
        }
        .parameters, .response {
            background: white;
            padding: 15px;
            border-radius: 5px;
            margin: 10px 0;
        }
        .parameters h4, .response h4 {
            color: #667eea;
            margin-bottom: 10px;
        }
        .code-block {
            background: #2d2d2d;
            color: #f8f8f2;
            padding: 15px;
            border-radius: 5px;
            overflow-x: auto;
            font-family: 'Courier New', monospace;
            font-size: 0.9em;
            margin: 10px 0;
        }
        .code-block pre {
            margin: 0;
        }
        .quick-start {
            background: #e8f4f8;
            padding: 20px;
            border-radius: 8px;
            margin-bottom: 20px;
        }
        .quick-start ol {
            margin-left: 20px;
        }
        .quick-start li {
            margin: 8px 0;
        }
        .example-box {
            background: #fff3cd;
            border: 1px solid #ffc107;
            padding: 15px;
            border-radius: 5px;
            margin: 10px 0;
        }
        .example-box h4 {
            color: #856404;
            margin-bottom: 10px;
        }
        footer {
            background: #f8f9fa;
            padding: 20px;
            text-align: center;
            color: #666;
            border-top: 1px solid #ddd;
        }
        @media (max-width: 768px) {
            header h1 {
                font-size: 1.8em;
            }
            .content {
                padding: 20px;
            }
            .endpoint-header {
                flex-direction: column;
                align-items: flex-start;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1>🕷️ CyberScraper 2077 API</h1>
            <p>Advanced Web Scraping API with AI-Powered Content Extraction</p>
            <span class="version">Version 1.0.0</span>
        </header>
        
        <div class="content">
            <div class="section">
                <h2>🚀 Quick Start</h2>
                <div class="quick-start">
                    <ol>
                        <li>Make a simple scrape request to <code>/api/scrape</code></li>
                        <li>For multiple requests, create a session first using <code>/api/session</code></li>
                        <li>Use the session ID for subsequent requests to <code>/api/session/{session_id}/scrape</code></li>
                        <li>Always close sessions when done using <code>DELETE /api/session/{session_id}</code></li>
                    </ol>
                </div>
            </div>

            <div class="section">
                <h2>📡 API Endpoints</h2>
                
                <div class="endpoint">
                    <div class="endpoint-header">
                        <span class="method get">GET</span>
                        <span class="path">/health</span>
                    </div>
                    <p class="description">Check if the API is running</p>
                    <div class="example-box">
                        <h4>Example:</h4>
                        <div class="code-block"><pre>curl https://grazieprego-scrapling.hf.space/health</pre></div>
                    </div>
                    <div class="response">
                        <h4>Response:</h4>
                        <div class="code-block"><pre>{
  "status": "ok",
  "message": "CyberScraper 2077 API is running"
}</pre></div>
                    </div>
                </div>

                <div class="endpoint">
                    <div class="endpoint-header">
                        <span class="method post">POST</span>
                        <span class="path">/api/scrape</span>
                    </div>
                    <p class="description">Stateless scrape request - creates a new extractor for each request</p>
                    <div class="parameters">
                        <h4>Request Body:</h4>
                        <ul>
                            <li><strong>url</strong> (string) - The URL to scrape</li>
                            <li><strong>query</strong> (string) - The extraction query/instruction</li>
                            <li><strong>model_name</strong> (string, optional) - AI model to use (default: 'alias-fast')</li>
                        </ul>
                    </div>
                    <div class="example-box">
                        <h4>Example (cURL):</h4>
                        <div class="code-block"><pre>curl -X POST https://grazieprego-scrapling.hf.space/api/scrape \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "query": "Extract all product prices"
  }'</pre></div>
                        <h4>Example (Python):</h4>
                        <div class="code-block"><pre>import requests

response = requests.post(
    'https://grazieprego-scrapling.hf.space/api/scrape',
    json={
        'url': 'https://example.com',
        'query': 'Extract prices'
    }
)
print(response.json())</pre></div>
                    </div>
                </div>

                <div class="endpoint">
                    <div class="endpoint-header">
                        <span class="method post">POST</span>
                        <span class="path">/api/session</span>
                    </div>
                    <p class="description">Create a persistent scraping session for multiple requests</p>
                    <div class="parameters">
                        <h4>Request Body:</h4>
                        <ul>
                            <li><strong>model_name</strong> (string, optional) - AI model to use (default: 'alias-fast')</li>
                        </ul>
                    </div>
                    <div class="example-box">
                        <h4>Example:</h4>
                        <div class="code-block"><pre>curl -X POST https://grazieprego-scrapling.hf.space/api/session \
  -H "Content-Type: application/json" \
  -d '{"model_name": "alias-fast"}'</pre></div>
                    </div>
                </div>

                <div class="endpoint">
                    <div class="endpoint-header">
                        <span class="method post">POST</span>
                        <span class="path">/api/session/{session_id}/scrape</span>
                    </div>
                    <p class="description">Scrape using an existing session context (more efficient for multiple requests)</p>
                    <div class="parameters">
                        <h4>Path Parameters:</h4>
                        <ul>
                            <li><strong>session_id</strong> (string) - UUID of the session</li>
                        </ul>
                        <h4>Request Body:</h4>
                        <ul>
                            <li><strong>url</strong> (string) - The URL to scrape</li>
                            <li><strong>query</strong> (string) - The extraction query</li>
                            <li><strong>model_name</strong> (string, optional)</li>
                        </ul>
                    </div>
                    <div class="example-box">
                        <h4>Example:</h4>
                        <div class="code-block"><pre>curl -X POST https://grazieprego-scrapling.hf.space/api/session/uuid-here/scrape \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/page1",
    "query": "Extract titles"
  }'</pre></div>
                    </div>
                </div>

                <div class="endpoint">
                    <div class="endpoint-header">
                        <span class="method delete">DELETE</span>
                        <span class="path">/api/session/{session_id}</span>
                    </div>
                    <p class="description">Close a session and release resources</p>
                    <div class="parameters">
                        <h4>Path Parameters:</h4>
                        <ul>
                            <li><strong>session_id</strong> (string) - UUID of the session to close</li>
                        </ul>
                    </div>
                    <div class="example-box">
                        <h4>Example:</h4>
                        <div class="code-block"><pre>curl -X DELETE https://grazieprego-scrapling.hf.space/api/session/uuid-here</pre></div>
                    </div>
                </div>
            </div>

            <div class="section">
                <h2>💡 Best Practices</h2>
                <ul>
                    <li>Use stateless <code>/api/scrape</code> for one-off requests</li>
                    <li>Use sessions for batch processing multiple URLs</li>
                    <li>Always close sessions when finished to free resources</li>
                    <li>Handle errors gracefully (500 errors may occur on complex sites)</li>
                    <li>Set appropriate timeouts for slow-loading pages</li>
                    <li>Implement retry logic for production use</li>
                </ul>
            </div>

            <div class="section">
                <h2>⚠️ Error Handling</h2>
                <div class="parameters">
                    <ul>
                        <li><strong>404</strong> - Session not found (for session endpoints)</li>
                        <li><strong>500</strong> - Internal server error - check the detail message</li>
                    </ul>
                    <p><strong>Common Issues:</strong></p>
                    <ul>
                        <li>URL unreachable or timeout</li>
                        <li>JavaScript-heavy sites may require different approaches</li>
                        <li>Bot protection may block requests</li>
                    </ul>
                </div>
            </div>
        </div>

        <footer>
            <p>CyberScraper 2077 API - Powered by Scrapling & AI</p>
            <p>Base URL: <a href="https://grazieprego-scrapling.hf.space">https://grazieprego-scrapling.hf.space</a></p>
        </footer>
    </div>
</body>
</html>