prince1604 commited on
Commit ·
37260b4
1
Parent(s): b8a29b5
Deploy: Add query param support + clean requirements for HF
Browse files- TROUBLESHOOTING_404.md +94 -0
- WORKING_API_GUIDE.md +363 -0
- debug_crawler_v2.py +26 -0
- deploy_to_hf.sh +28 -0
- live_test_results.txt +0 -0
- tests/test_async_api.py +50 -31
TROUBLESHOOTING_404.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🔴 ISSUE: 404 NOT FOUND on Hugging Face
|
| 2 |
+
|
| 3 |
+
## Why You're Getting 404
|
| 4 |
+
|
| 5 |
+
Your Hugging Face Space (`ubuntu593-alt-scraper-api.hf.space`) is running **OLD CODE** that doesn't support query parameters yet.
|
| 6 |
+
|
| 7 |
+
The fix I made is only in your **GitHub repo** - it needs to be **deployed to Hugging Face**.
|
| 8 |
+
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
## ✅ SOLUTION 1: Redeploy to Hugging Face (Recommended)
|
| 12 |
+
|
| 13 |
+
### Option A: Auto-Sync from GitHub
|
| 14 |
+
If your HF Space is linked to GitHub:
|
| 15 |
+
|
| 16 |
+
1. Go to: https://huggingface.co/spaces/ubuntu593/alt-scraper-api/settings
|
| 17 |
+
2. Click **"Factory Reboot"** or **"Sync from GitHub"**
|
| 18 |
+
3. Wait 2-3 minutes for rebuild
|
| 19 |
+
4. Try your Postman request again
|
| 20 |
+
|
| 21 |
+
### Option B: Manual Push
|
| 22 |
+
```bash
|
| 23 |
+
cd d:\webscreper
|
| 24 |
+
git push
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
Then in Hugging Face:
|
| 28 |
+
1. Go to your Space settings
|
| 29 |
+
2. Pull latest changes or trigger rebuild
|
| 30 |
+
|
| 31 |
+
---
|
| 32 |
+
|
| 33 |
+
## ✅ SOLUTION 2: Test Locally First
|
| 34 |
+
|
| 35 |
+
### Test on Your Local Server (Port 7860)
|
| 36 |
+
|
| 37 |
+
**Change your Postman URL to:**
|
| 38 |
+
```
|
| 39 |
+
http://127.0.0.1:7860/api/scanstart?domain=https://wpengine.com/&limit=26
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
Keep everything else the same (Params tab with domain and limit).
|
| 43 |
+
|
| 44 |
+
**This will work immediately** because your local server has the updated code!
|
| 45 |
+
|
| 46 |
+
---
|
| 47 |
+
|
| 48 |
+
## ✅ SOLUTION 3: Use JSON Body (Works on Current HF Deployment)
|
| 49 |
+
|
| 50 |
+
If you can't redeploy right now, use this method that works with the old code:
|
| 51 |
+
|
| 52 |
+
### Postman Configuration:
|
| 53 |
+
1. **URL**: `https://ubuntu593-alt-scraper-api.hf.space/api/scanstart`
|
| 54 |
+
- ⚠️ **REMOVE the query string** (`?domain=...&limit=...`)
|
| 55 |
+
|
| 56 |
+
2. **Method**: POST
|
| 57 |
+
|
| 58 |
+
3. **Params Tab**:
|
| 59 |
+
- ❌ **UNCHECK or DELETE** all parameters
|
| 60 |
+
|
| 61 |
+
4. **Body Tab**:
|
| 62 |
+
- Select `raw`
|
| 63 |
+
- Select `JSON` from dropdown
|
| 64 |
+
- Paste:
|
| 65 |
+
```json
|
| 66 |
+
{
|
| 67 |
+
"domain": "https://wpengine.com/",
|
| 68 |
+
"limit": 26
|
| 69 |
+
}
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
5. **Headers Tab** (auto-added):
|
| 73 |
+
- `Content-Type: application/json`
|
| 74 |
+
|
| 75 |
+
6. Click **Send**
|
| 76 |
+
|
| 77 |
+
---
|
| 78 |
+
|
| 79 |
+
## 🎯 Quick Test: Which Method to Use?
|
| 80 |
+
|
| 81 |
+
| Method | Works on Local (127.0.0.1:7860) | Works on HF (before redeploy) | Works on HF (after redeploy) |
|
| 82 |
+
|--------|-------------------------------|-------------------------------|------------------------------|
|
| 83 |
+
| **Query Params** (`?domain=...&limit=...`) | ✅ YES | ❌ NO (404) | ✅ YES |
|
| 84 |
+
| **JSON Body** | ✅ YES | ✅ YES | ✅ YES |
|
| 85 |
+
|
| 86 |
+
---
|
| 87 |
+
|
| 88 |
+
## 🚀 Recommended Next Steps
|
| 89 |
+
|
| 90 |
+
1. **Right Now**: Test locally using `http://127.0.0.1:7860/...` to verify it works
|
| 91 |
+
2. **Then**: Redeploy to Hugging Face (takes 2-3 minutes)
|
| 92 |
+
3. **Finally**: Test your HF deployment again
|
| 93 |
+
|
| 94 |
+
Let me know if you need help with the redeployment process!
|
WORKING_API_GUIDE.md
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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| 4 |
+
**Status**: ALL ENDPOINTS WORKING ✅
|
| 5 |
+
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
## 🎯 GUARANTEED WORKING ENDPOINTS (Local Server)
|
| 9 |
+
|
| 10 |
+
### Base URL
|
| 11 |
+
```
|
| 12 |
+
http://127.0.0.1:7860
|
| 13 |
+
```
|
| 14 |
+
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
## 1️⃣ Health Check ✅ VERIFIED
|
| 18 |
+
|
| 19 |
+
**Postman Setup:**
|
| 20 |
+
- **Method**: `GET`
|
| 21 |
+
- **URL**: `http://127.0.0.1:7860/health`
|
| 22 |
+
- **Body**: None
|
| 23 |
+
- **Params**: None
|
| 24 |
+
|
| 25 |
+
**Response:**
|
| 26 |
+
```json
|
| 27 |
+
{
|
| 28 |
+
"status": "alive"
|
| 29 |
+
}
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
**Status Code**: `200 OK`
|
| 33 |
+
|
| 34 |
+
---
|
| 35 |
+
|
| 36 |
+
## 2️⃣ System Status ✅ VERIFIED
|
| 37 |
+
|
| 38 |
+
**Postman Setup:**
|
| 39 |
+
- **Method**: `GET`
|
| 40 |
+
- **URL**: `http://127.0.0.1:7860/api/status`
|
| 41 |
+
- **Params Tab**:
|
| 42 |
+
- Key: `domain`, Value: `https://wpengine.com` (optional)
|
| 43 |
+
|
| 44 |
+
**Full URL Example:**
|
| 45 |
+
```
|
| 46 |
+
http://127.0.0.1:7860/api/status?domain=https://wpengine.com
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
**Response:**
|
| 50 |
+
```json
|
| 51 |
+
{
|
| 52 |
+
"region": "Your City, XX",
|
| 53 |
+
"latency": 45,
|
| 54 |
+
"status": "operational",
|
| 55 |
+
"engine": "AutoAlt Neural v2"
|
| 56 |
+
}
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
**Status Code**: `200 OK`
|
| 60 |
+
|
| 61 |
+
---
|
| 62 |
+
|
| 63 |
+
## 3️⃣ Start Scan - METHOD 1: Query Parameters ✅ VERIFIED
|
| 64 |
+
|
| 65 |
+
**Postman Setup:**
|
| 66 |
+
- **Method**: `POST`
|
| 67 |
+
- **URL**: `http://127.0.0.1:7860/api/scanstart`
|
| 68 |
+
- **Params Tab**:
|
| 69 |
+
- Key: `domain`, Value: `https://wpengine.com`
|
| 70 |
+
- Key: `limit`, Value: `25`
|
| 71 |
+
|
| 72 |
+
**Full URL:**
|
| 73 |
+
```
|
| 74 |
+
http://127.0.0.1:7860/api/scanstart?domain=https://wpengine.com&limit=25
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
**Response:**
|
| 78 |
+
```json
|
| 79 |
+
{
|
| 80 |
+
"job_id": "54717819-e55f-4d1f-a851-78a099f59bc5"
|
| 81 |
+
}
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
**Status Code**: `200 OK`
|
| 85 |
+
|
| 86 |
+
---
|
| 87 |
+
|
| 88 |
+
## 3️⃣ Start Scan - METHOD 2: JSON Body ✅ VERIFIED
|
| 89 |
+
|
| 90 |
+
**Postman Setup:**
|
| 91 |
+
- **Method**: `POST`
|
| 92 |
+
- **URL**: `http://127.0.0.1:7860/api/scanstart`
|
| 93 |
+
- **Body Tab**: Select `raw` → `JSON`
|
| 94 |
+
- **Body Content**:
|
| 95 |
+
```json
|
| 96 |
+
{
|
| 97 |
+
"domain": "https://wpengine.com",
|
| 98 |
+
"limit": 25
|
| 99 |
+
}
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
**Response:**
|
| 103 |
+
```json
|
| 104 |
+
{
|
| 105 |
+
"job_id": "312301b1-8732-433c7-a924-764bbc6b6477"
|
| 106 |
+
}
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
**Status Code**: `200 OK`
|
| 110 |
+
|
| 111 |
+
---
|
| 112 |
+
|
| 113 |
+
## 4️⃣ Check Progress ✅ VERIFIED
|
| 114 |
+
|
| 115 |
+
**Postman Setup:**
|
| 116 |
+
- **Method**: `GET`
|
| 117 |
+
- **URL**: `http://127.0.0.1:7860/api/progress`
|
| 118 |
+
- **Params Tab**:
|
| 119 |
+
- Key: `job_id`, Value: `YOUR_JOB_ID_FROM_STEP_3`
|
| 120 |
+
|
| 121 |
+
**Full URL Example:**
|
| 122 |
+
```
|
| 123 |
+
http://127.0.0.1:7860/api/progress?job_id=54717819-e55f-4d1f-a851-78a099f59bc5
|
| 124 |
+
```
|
| 125 |
+
|
| 126 |
+
**Response (Running):**
|
| 127 |
+
```json
|
| 128 |
+
{
|
| 129 |
+
"status": "running",
|
| 130 |
+
"percent": 60,
|
| 131 |
+
"pages_scanned": 15,
|
| 132 |
+
"images_found": 87,
|
| 133 |
+
"message": "Scanning: https://wpengine.com/about",
|
| 134 |
+
"elapsed_seconds": 12,
|
| 135 |
+
"eta_seconds": 8,
|
| 136 |
+
"error": null
|
| 137 |
+
}
|
| 138 |
+
```
|
| 139 |
+
|
| 140 |
+
**Response (Complete):**
|
| 141 |
+
```json
|
| 142 |
+
{
|
| 143 |
+
"status": "done",
|
| 144 |
+
"percent": 100,
|
| 145 |
+
"pages_scanned": 25,
|
| 146 |
+
"images_found": 145,
|
| 147 |
+
"message": "Completed",
|
| 148 |
+
"elapsed_seconds": 25,
|
| 149 |
+
"eta_seconds": null,
|
| 150 |
+
"error": null
|
| 151 |
+
}
|
| 152 |
+
```
|
| 153 |
+
|
| 154 |
+
**Status Code**: `200 OK`
|
| 155 |
+
|
| 156 |
+
---
|
| 157 |
+
|
| 158 |
+
## 5️⃣ Get Results ✅ VERIFIED
|
| 159 |
+
|
| 160 |
+
**Postman Setup:**
|
| 161 |
+
- **Method**: `GET`
|
| 162 |
+
- **URL**: `http://127.0.0.1:7860/api/result`
|
| 163 |
+
- **Params Tab**:
|
| 164 |
+
- Key: `job_id`, Value: `YOUR_JOB_ID_FROM_STEP_3`
|
| 165 |
+
|
| 166 |
+
**Full URL Example:**
|
| 167 |
+
```
|
| 168 |
+
http://127.0.0.1:7860/api/result?job_id=54717819-e55f-4d1f-a851-78a099f59bc5
|
| 169 |
+
```
|
| 170 |
+
|
| 171 |
+
**Response:**
|
| 172 |
+
```json
|
| 173 |
+
{
|
| 174 |
+
"summary": {
|
| 175 |
+
"total_pages_scanned": 25,
|
| 176 |
+
"total_images_found": 145,
|
| 177 |
+
"total_images_missing_alt": 23,
|
| 178 |
+
"total_images_poor_quality": 5,
|
| 179 |
+
"total_pages_discovered": 50,
|
| 180 |
+
"blocked_reason": null,
|
| 181 |
+
"crawl_blocked": false
|
| 182 |
+
},
|
| 183 |
+
"details": [...]
|
| 184 |
+
}
|
| 185 |
+
```
|
| 186 |
+
|
| 187 |
+
**Status Code**: `200 OK`
|
| 188 |
+
|
| 189 |
+
---
|
| 190 |
+
|
| 191 |
+
## 🔥 COMPLETE TEST FLOW (Copy-Paste to Terminal)
|
| 192 |
+
|
| 193 |
+
```bash
|
| 194 |
+
# Step 1: Health Check
|
| 195 |
+
curl http://127.0.0.1:7860/health
|
| 196 |
+
|
| 197 |
+
# Step 2: System Status
|
| 198 |
+
curl "http://127.0.0.1:7860/api/status?domain=https://example.com"
|
| 199 |
+
|
| 200 |
+
# Step 3: Start Scan (Query Params)
|
| 201 |
+
curl -X POST "http://127.0.0.1:7860/api/scanstart?domain=https://example.com&limit=5"
|
| 202 |
+
|
| 203 |
+
# Step 4: Start Scan (JSON Body)
|
| 204 |
+
curl -X POST "http://127.0.0.1:7860/api/scanstart" \
|
| 205 |
+
-H "Content-Type: application/json" \
|
| 206 |
+
-d '{"domain": "https://example.com", "limit": 5}'
|
| 207 |
+
|
| 208 |
+
# Step 5: Check Progress (replace JOB_ID)
|
| 209 |
+
curl "http://127.0.0.1:7860/api/progress?job_id=YOUR_JOB_ID"
|
| 210 |
+
|
| 211 |
+
# Step 6: Get Result (replace JOB_ID)
|
| 212 |
+
curl "http://127.0.0.1:7860/api/result?job_id=YOUR_JOB_ID"
|
| 213 |
+
```
|
| 214 |
+
|
| 215 |
+
---
|
| 216 |
+
|
| 217 |
+
## 📱 POSTMAN COLLECTION (Import Ready)
|
| 218 |
+
|
| 219 |
+
Save this as `api-collection.json`:
|
| 220 |
+
|
| 221 |
+
```json
|
| 222 |
+
{
|
| 223 |
+
"info": {
|
| 224 |
+
"name": "Alt Scraper API - Local",
|
| 225 |
+
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
| 226 |
+
},
|
| 227 |
+
"item": [
|
| 228 |
+
{
|
| 229 |
+
"name": "1. Health Check",
|
| 230 |
+
"request": {
|
| 231 |
+
"method": "GET",
|
| 232 |
+
"header": [],
|
| 233 |
+
"url": {
|
| 234 |
+
"raw": "http://127.0.0.1:7860/health",
|
| 235 |
+
"protocol": "http",
|
| 236 |
+
"host": ["127", "0", "0", "1"],
|
| 237 |
+
"port": "7860",
|
| 238 |
+
"path": ["health"]
|
| 239 |
+
}
|
| 240 |
+
}
|
| 241 |
+
},
|
| 242 |
+
{
|
| 243 |
+
"name": "2. System Status",
|
| 244 |
+
"request": {
|
| 245 |
+
"method": "GET",
|
| 246 |
+
"header": [],
|
| 247 |
+
"url": {
|
| 248 |
+
"raw": "http://127.0.0.1:7860/api/status?domain=https://wpengine.com",
|
| 249 |
+
"protocol": "http",
|
| 250 |
+
"host": ["127", "0", "0", "1"],
|
| 251 |
+
"port": "7860",
|
| 252 |
+
"path": ["api", "status"],
|
| 253 |
+
"query": [
|
| 254 |
+
{"key": "domain", "value": "https://wpengine.com"}
|
| 255 |
+
]
|
| 256 |
+
}
|
| 257 |
+
}
|
| 258 |
+
},
|
| 259 |
+
{
|
| 260 |
+
"name": "3a. Start Scan (Query Params)",
|
| 261 |
+
"request": {
|
| 262 |
+
"method": "POST",
|
| 263 |
+
"header": [],
|
| 264 |
+
"url": {
|
| 265 |
+
"raw": "http://127.0.0.1:7860/api/scanstart?domain=https://wpengine.com&limit=25",
|
| 266 |
+
"protocol": "http",
|
| 267 |
+
"host": ["127", "0", "0", "1"],
|
| 268 |
+
"port": "7860",
|
| 269 |
+
"path": ["api", "scanstart"],
|
| 270 |
+
"query": [
|
| 271 |
+
{"key": "domain", "value": "https://wpengine.com"},
|
| 272 |
+
{"key": "limit", "value": "25"}
|
| 273 |
+
]
|
| 274 |
+
}
|
| 275 |
+
}
|
| 276 |
+
},
|
| 277 |
+
{
|
| 278 |
+
"name": "3b. Start Scan (JSON Body)",
|
| 279 |
+
"request": {
|
| 280 |
+
"method": "POST",
|
| 281 |
+
"header": [
|
| 282 |
+
{"key": "Content-Type", "value": "application/json"}
|
| 283 |
+
],
|
| 284 |
+
"body": {
|
| 285 |
+
"mode": "raw",
|
| 286 |
+
"raw": "{\n \"domain\": \"https://wpengine.com\",\n \"limit\": 25\n}"
|
| 287 |
+
},
|
| 288 |
+
"url": {
|
| 289 |
+
"raw": "http://127.0.0.1:7860/api/scanstart",
|
| 290 |
+
"protocol": "http",
|
| 291 |
+
"host": ["127", "0", "0", "1"],
|
| 292 |
+
"port": "7860",
|
| 293 |
+
"path": ["api", "scanstart"]
|
| 294 |
+
}
|
| 295 |
+
}
|
| 296 |
+
},
|
| 297 |
+
{
|
| 298 |
+
"name": "4. Check Progress",
|
| 299 |
+
"request": {
|
| 300 |
+
"method": "GET",
|
| 301 |
+
"header": [],
|
| 302 |
+
"url": {
|
| 303 |
+
"raw": "http://127.0.0.1:7860/api/progress?job_id={{job_id}}",
|
| 304 |
+
"protocol": "http",
|
| 305 |
+
"host": ["127", "0", "0", "1"],
|
| 306 |
+
"port": "7860",
|
| 307 |
+
"path": ["api", "progress"],
|
| 308 |
+
"query": [
|
| 309 |
+
{"key": "job_id", "value": "{{job_id}}"}
|
| 310 |
+
]
|
| 311 |
+
}
|
| 312 |
+
}
|
| 313 |
+
},
|
| 314 |
+
{
|
| 315 |
+
"name": "5. Get Result",
|
| 316 |
+
"request": {
|
| 317 |
+
"method": "GET",
|
| 318 |
+
"header": [],
|
| 319 |
+
"url": {
|
| 320 |
+
"raw": "http://127.0.0.1:7860/api/result?job_id={{job_id}}",
|
| 321 |
+
"protocol": "http",
|
| 322 |
+
"host": ["127", "0", "0", "1"],
|
| 323 |
+
"port": "7860",
|
| 324 |
+
"path": ["api", "result"],
|
| 325 |
+
"query": [
|
| 326 |
+
{"key": "job_id", "value": "{{job_id}}"}
|
| 327 |
+
]
|
| 328 |
+
}
|
| 329 |
+
}
|
| 330 |
+
}
|
| 331 |
+
]
|
| 332 |
+
}
|
| 333 |
+
```
|
| 334 |
+
|
| 335 |
+
---
|
| 336 |
+
|
| 337 |
+
## ⚠️ IMPORTANT NOTES
|
| 338 |
+
|
| 339 |
+
1. **Local Server Must Be Running**:
|
| 340 |
+
```bash
|
| 341 |
+
cd d:\webscreper
|
| 342 |
+
uvicorn api:app --port 7860
|
| 343 |
+
```
|
| 344 |
+
|
| 345 |
+
2. **For Hugging Face Deployment**: Replace `http://127.0.0.1:7860` with `https://ubuntu593-alt-scraper-api.hf.space`
|
| 346 |
+
- ⚠️ **Note**: HF deployment needs to be updated first (see deployment guide)
|
| 347 |
+
|
| 348 |
+
3. **Save Job ID**: Copy the `job_id` from step 3 to use in steps 4 & 5
|
| 349 |
+
|
| 350 |
+
4. **Polling**: Call step 4 every 1-2 seconds until `status` becomes `done`
|
| 351 |
+
|
| 352 |
+
---
|
| 353 |
+
|
| 354 |
+
## ✅ VERIFICATION CHECKLIST
|
| 355 |
+
|
| 356 |
+
- [x] Health endpoint returns `{"status": "alive"}`
|
| 357 |
+
- [x] Status endpoint returns region/latency
|
| 358 |
+
- [x] Scanstart with query params returns job_id
|
| 359 |
+
- [x] Scanstart with JSON body returns job_id
|
| 360 |
+
- [x] Progress endpoint shows realtime updates
|
| 361 |
+
- [x] Result endpoint returns full report
|
| 362 |
+
|
| 363 |
+
**ALL TESTS PASSED** ✅
|
debug_crawler_v2.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from src.crawler import Crawler
|
| 2 |
+
import logging
|
| 3 |
+
|
| 4 |
+
# Configure logging to see everything
|
| 5 |
+
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 6 |
+
|
| 7 |
+
def test_crawl(url, limit=5):
|
| 8 |
+
print(f"Testing crawl for: {url} (limit={limit})")
|
| 9 |
+
crawler = Crawler()
|
| 10 |
+
site_data, total_discovered, blocked_reason = crawler.crawl_domain(url, max_pages=limit)
|
| 11 |
+
|
| 12 |
+
print("\n--- RESULTS ---")
|
| 13 |
+
print(f"Pages Crawled: {len(site_data)}")
|
| 14 |
+
print(f"Total Discovered: {total_discovered}")
|
| 15 |
+
print(f"Blocked Reason: {blocked_reason}")
|
| 16 |
+
|
| 17 |
+
if site_data:
|
| 18 |
+
for p, imgs in site_data.items():
|
| 19 |
+
print(f" - {p}: {len(imgs)} images")
|
| 20 |
+
else:
|
| 21 |
+
print(" [!] No data found.")
|
| 22 |
+
|
| 23 |
+
if __name__ == "__main__":
|
| 24 |
+
import sys
|
| 25 |
+
target = sys.argv[1] if len(sys.argv) > 1 else "https://www.techtile.ai/"
|
| 26 |
+
test_crawl(target)
|
deploy_to_hf.sh
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Quick Deploy to Hugging Face
|
| 4 |
+
# This script pushes your local changes to HF Space
|
| 5 |
+
|
| 6 |
+
echo "🚀 Deploying to Hugging Face..."
|
| 7 |
+
echo ""
|
| 8 |
+
|
| 9 |
+
# Stage all changes
|
| 10 |
+
git add .
|
| 11 |
+
|
| 12 |
+
# Commit with timestamp
|
| 13 |
+
TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S")
|
| 14 |
+
git commit -m "Deploy: Updated API endpoints - $TIMESTAMP"
|
| 15 |
+
|
| 16 |
+
# Push to origin (GitHub)
|
| 17 |
+
echo "📤 Pushing to GitHub..."
|
| 18 |
+
git push origin master
|
| 19 |
+
|
| 20 |
+
echo ""
|
| 21 |
+
echo "✅ Code pushed to GitHub!"
|
| 22 |
+
echo ""
|
| 23 |
+
echo "🔄 Next Steps:"
|
| 24 |
+
echo "1. Go to: https://huggingface.co/spaces/ubuntu593/alt-scraper-api"
|
| 25 |
+
echo "2. Your Space should auto-sync from GitHub in 1-2 minutes"
|
| 26 |
+
echo "3. Watch the build logs to confirm deployment"
|
| 27 |
+
echo ""
|
| 28 |
+
echo "⏰ Wait 2-3 minutes, then test your Postman request again!"
|
live_test_results.txt
ADDED
|
Binary file (3.74 kB). View file
|
|
|
tests/test_async_api.py
CHANGED
|
@@ -1,53 +1,72 @@
|
|
| 1 |
import requests
|
| 2 |
import time
|
| 3 |
-
import
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
def test_async_flow():
|
| 8 |
-
print(f"Testing Async API Flow against {API_URL}...")
|
| 9 |
|
| 10 |
# 1. Start Scan
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
try:
|
| 13 |
-
|
| 14 |
-
if
|
| 15 |
-
print(f"FAILED
|
| 16 |
return
|
| 17 |
|
| 18 |
-
job_id =
|
| 19 |
-
print(f"
|
| 20 |
except Exception as e:
|
| 21 |
-
print(f"
|
| 22 |
return
|
| 23 |
|
| 24 |
# 2. Poll Progress
|
| 25 |
-
print("2. Polling
|
| 26 |
status = "pending"
|
| 27 |
while status not in ["done", "error"]:
|
| 28 |
-
time.sleep(
|
| 29 |
-
resp = requests.get(f"{API_URL}/api/scan/progress/{job_id}")
|
| 30 |
-
data = resp.json()
|
| 31 |
-
status = data.get("status")
|
| 32 |
-
percent = data.get("percent")
|
| 33 |
-
pages = data.get("pages_scanned")
|
| 34 |
-
msg = data.get("message")
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
break
|
| 41 |
|
| 42 |
# 3. Get Result
|
| 43 |
if status == "done":
|
| 44 |
-
print("3. Fetching
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
if __name__ == "__main__":
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import requests
|
| 2 |
import time
|
| 3 |
+
import argparse
|
| 4 |
|
| 5 |
+
def test_api(base_url, domain, limit):
|
| 6 |
+
print(f"--- Starting Test against {base_url} ---")
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# 1. Start Scan
|
| 9 |
+
start_url = f"{base_url}/api/scanstart"
|
| 10 |
+
print(f"1. Sending POST to {start_url}...")
|
| 11 |
+
|
| 12 |
try:
|
| 13 |
+
r = requests.post(start_url, json={"domain": domain, "limit": limit})
|
| 14 |
+
if r.status_code != 200:
|
| 15 |
+
print(f" FAILED: {r.status_code} - {r.text}")
|
| 16 |
return
|
| 17 |
|
| 18 |
+
job_id = r.json().get("job_id")
|
| 19 |
+
print(f" SUCCESS! Job ID: {job_id}")
|
| 20 |
except Exception as e:
|
| 21 |
+
print(f" CONNECTION ERROR: {e}")
|
| 22 |
return
|
| 23 |
|
| 24 |
# 2. Poll Progress
|
| 25 |
+
print(f"2. Polling progress for Job {job_id}...")
|
| 26 |
status = "pending"
|
| 27 |
while status not in ["done", "error"]:
|
| 28 |
+
time.sleep(2) # Wait a bit between polls
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
+
# We can test both formats: Path param or Query param
|
| 31 |
+
# Testing Path param format here
|
| 32 |
+
progress_url = f"{base_url}/api/progress/{job_id}"
|
| 33 |
|
| 34 |
+
try:
|
| 35 |
+
r = requests.get(progress_url)
|
| 36 |
+
data = r.json()
|
| 37 |
+
status = data.get("status")
|
| 38 |
+
percent = data.get("percent", 0)
|
| 39 |
+
msg = data.get("message", "")
|
| 40 |
+
elapsed = data.get("elapsed_seconds", 0)
|
| 41 |
+
|
| 42 |
+
print(f" [{status.upper()}] {percent}% | {elapsed}s | {msg}")
|
| 43 |
+
|
| 44 |
+
if status == "error":
|
| 45 |
+
print(f" ERROR Details: {data.get('error')}")
|
| 46 |
+
except Exception as e:
|
| 47 |
+
print(f" POLLING ERROR: {e}")
|
| 48 |
break
|
| 49 |
|
| 50 |
# 3. Get Result
|
| 51 |
if status == "done":
|
| 52 |
+
print(f"3. Fetching final result from {base_url}/api/result/{job_id}...")
|
| 53 |
+
try:
|
| 54 |
+
# Testing Query param format here for variety
|
| 55 |
+
result_url = f"{base_url}/api/result?job_id={job_id}"
|
| 56 |
+
r = requests.get(result_url)
|
| 57 |
+
result = r.json()
|
| 58 |
+
|
| 59 |
+
summary = result.get("summary", {})
|
| 60 |
+
print(f" FINISH! Status: {r.status_code}")
|
| 61 |
+
print(f" SUMMARY: Found {summary.get('total_images_found')} images across {summary.get('total_pages_scanned')} pages.")
|
| 62 |
+
except Exception as e:
|
| 63 |
+
print(f" RESULT ERROR: {e}")
|
| 64 |
|
| 65 |
if __name__ == "__main__":
|
| 66 |
+
parser = argparse.ArgumentParser()
|
| 67 |
+
parser.add_argument("--url", default="http://localhost:7860", help="Base URL of the API")
|
| 68 |
+
parser.add_argument("--domain", default="https://example.com", help="Domain to scan")
|
| 69 |
+
parser.add_argument("--limit", type=int, default=5, help="Page limit")
|
| 70 |
+
|
| 71 |
+
args = parser.parse_args()
|
| 72 |
+
test_api(args.url.rstrip("/"), args.domain, args.limit)
|