prince1604 commited on
Commit
c3a843f
·
1 Parent(s): 7db0953

Update README and add HF deployment verification

Browse files
Files changed (3) hide show
  1. HF_DEPLOYMENT_STATUS.md +223 -0
  2. README.md +62 -9
  3. verify_hf_deployment.py +111 -0
HF_DEPLOYMENT_STATUS.md ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🚀 HUGGING FACE DEPLOYMENT - COMPLETE GUIDE
2
+
3
+ ## ✅ Code Successfully Pushed to GitHub
4
+ **Commit**: `37260b4 - Deploy: Add query param support + clean requirements for HF`
5
+ **Status**: Pushed to `master` branch
6
+
7
+ ---
8
+
9
+ ## 🔄 STEP 1: Trigger Hugging Face Rebuild
10
+
11
+ ### Option A: Auto-Sync (If configured)
12
+ Your HF Space should automatically detect the GitHub push and rebuild in **1-2 minutes**.
13
+
14
+ **Monitor here**: https://huggingface.co/spaces/ubuntu593/alt-scraper-api
15
+
16
+ ### Option B: Manual Trigger
17
+ If auto-sync isn't working:
18
+
19
+ 1. Go to: https://huggingface.co/spaces/ubuntu593/alt-scraper-api/settings
20
+ 2. Scroll to **"Sleeping Behavior"**
21
+ 3. Click **"Factory Reboot"** or **"Restart Space"**
22
+ 4. Wait 2-3 minutes for rebuild
23
+
24
+ ---
25
+
26
+ ## ⏰ STEP 2: Wait for Build (2-3 minutes)
27
+
28
+ Watch the build logs at:
29
+ https://huggingface.co/spaces/ubuntu593/alt-scraper-api/logs
30
+
31
+ **Look for these success messages:**
32
+ ```
33
+ Installing dependencies...
34
+ ✓ fastapi installed
35
+ ✓ playwright-stealth installed
36
+ ✓ All dependencies installed
37
+ Starting uvicorn...
38
+ Application startup complete
39
+ ```
40
+
41
+ ---
42
+
43
+ ## ✅ STEP 3: Verify Deployment
44
+
45
+ ### Test 1: Health Check
46
+ Open in browser or Postman:
47
+ ```
48
+ https://ubuntu593-alt-scraper-api.hf.space/health
49
+ ```
50
+
51
+ **Expected**: `{"status": "alive"}`
52
+
53
+ ---
54
+
55
+ ### Test 2: System Status
56
+ ```
57
+ https://ubuntu593-alt-scraper-api.hf.space/api/status?domain=https://wpengine.com
58
+ ```
59
+
60
+ **Expected**: JSON with region, latency, status
61
+
62
+ ---
63
+
64
+ ### Test 3: Start Scan (Query Params) - YOUR ORIGINAL REQUEST ✅
65
+
66
+ **Postman Configuration:**
67
+ - **Method**: `POST`
68
+ - **URL**: `https://ubuntu593-alt-scraper-api.hf.space/api/scanstart`
69
+ - **Params Tab**:
70
+ - `domain` = `https://wpengine.com`
71
+ - `limit` = `26`
72
+
73
+ **Full URL:**
74
+ ```
75
+ https://ubuntu593-alt-scraper-api.hf.space/api/scanstart?domain=https://wpengine.com&limit=26
76
+ ```
77
+
78
+ **Expected Response:**
79
+ ```json
80
+ {
81
+ "job_id": "abc-123-def-456"
82
+ }
83
+ ```
84
+
85
+ ---
86
+
87
+ ### Test 4: Start Scan (JSON Body Alternative)
88
+
89
+ **Postman Configuration:**
90
+ - **Method**: `POST`
91
+ - **URL**: `https://ubuntu593-alt-scraper-api.hf.space/api/scanstart`
92
+ - **Body**: raw → JSON
93
+ ```json
94
+ {
95
+ "domain": "https://wpengine.com",
96
+ "limit": 26
97
+ }
98
+ ```
99
+
100
+ **Expected Response:**
101
+ ```json
102
+ {
103
+ "job_id": "xyz-789-ghi-012"
104
+ }
105
+ ```
106
+
107
+ ---
108
+
109
+ ### Test 5: Check Progress
110
+
111
+ Use the `job_id` from Test 3 or 4:
112
+ ```
113
+ https://ubuntu593-alt-scraper-api.hf.space/api/progress?job_id=YOUR_JOB_ID
114
+ ```
115
+
116
+ **Expected Response:**
117
+ ```json
118
+ {
119
+ "status": "running",
120
+ "percent": 45,
121
+ "pages_scanned": 12,
122
+ "images_found": 87,
123
+ "message": "Scanning: https://wpengine.com/about",
124
+ "elapsed_seconds": 10,
125
+ "eta_seconds": 12,
126
+ "error": null
127
+ }
128
+ ```
129
+
130
+ ---
131
+
132
+ ### Test 6: Get Final Result
133
+
134
+ When status is "done":
135
+ ```
136
+ https://ubuntu593-alt-scraper-api.hf.space/api/result?job_id=YOUR_JOB_ID
137
+ ```
138
+
139
+ **Expected Response:**
140
+ ```json
141
+ {
142
+ "summary": {
143
+ "total_pages_scanned": 26,
144
+ "total_images_found": 150,
145
+ ...
146
+ },
147
+ "details": [...]
148
+ }
149
+ ```
150
+
151
+ ---
152
+
153
+ ## 🔍 TROUBLESHOOTING
154
+
155
+ ### If You Still Get 404:
156
+
157
+ 1. **Check Build Status**:
158
+ - Go to https://huggingface.co/spaces/ubuntu593/alt-scraper-api
159
+ - Look for "Building..." or "Running" badge
160
+ - If "Stopped", click "Restart Space"
161
+
162
+ 2. **Check Build Logs**:
163
+ - https://huggingface.co/spaces/ubuntu593/alt-scraper-api/logs
164
+ - Look for errors in dependency installation
165
+
166
+ 3. **Verify Git Sync**:
167
+ - HF Space Settings → Repository
168
+ - Ensure it's linked to: `https://github.com/prince1604/Alt-scraper-api`
169
+ - Check "Auto-update from GitHub" is enabled
170
+
171
+ 4. **Force Rebuild**:
172
+ - Settings → Factory Reboot
173
+ - Wait 3-5 minutes
174
+
175
+ ---
176
+
177
+ ## 📊 DEPLOYMENT TIMELINE
178
+
179
+ | Time | Action | Status |
180
+ |------|--------|--------|
181
+ | T+0min | Code pushed to GitHub | ✅ COMPLETE |
182
+ | T+1min | HF detects changes | ⏳ WAITING |
183
+ | T+2min | Build starts | ⏳ IN PROGRESS |
184
+ | T+5min | Build completes | ⏳ PENDING |
185
+ | T+6min | **API READY TO TEST** | 🎯 READY |
186
+
187
+ ---
188
+
189
+ ## ✅ SUCCESS CRITERIA
190
+
191
+ Your deployment is successful when:
192
+
193
+ - [ ] Health endpoint returns `{"status": "alive"}`
194
+ - [ ] Status endpoint returns region info
195
+ - [ ] Scanstart with query params (`?domain=...&limit=...`) returns job_id
196
+ - [ ] Scanstart with JSON body also works
197
+ - [ ] Progress tracking shows real-time updates
198
+ - [ ] Result endpoint returns full scan report
199
+
200
+ ---
201
+
202
+ ## 🎯 YOUR EXACT WORKING URL (After Deployment)
203
+
204
+ ```
205
+ POST https://ubuntu593-alt-scraper-api.hf.space/api/scanstart?domain=https://wpengine.com&limit=26
206
+ ```
207
+
208
+ **This URL will work in Postman with Params tab exactly as you configured!**
209
+
210
+ ---
211
+
212
+ ## ⚡ NEXT STEPS
213
+
214
+ 1. Wait **2-3 minutes** for HF rebuild
215
+ 2. Test health endpoint first
216
+ 3. Then test your scanstart request
217
+ 4. If it works → You're done! ✅
218
+ 5. If still 404 → Check troubleshooting section above
219
+
220
+ ---
221
+
222
+ **Status**: Code deployed. Waiting for HF build completion...
223
+ **ETA**: 2-3 minutes from now (17:23 IST)
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Alt Scraper Api
3
  emoji: 🕷️
4
  colorFrom: purple
5
  colorTo: blue
@@ -10,15 +10,68 @@ app_port: 7860
10
 
11
  # Alt Scraper API
12
 
13
- A robust SEO scraping API built with Python, Flask, and Playwright. Hostable for free on Hugging Face Spaces.
14
 
15
- ## Usage
16
 
17
- **Endpoint:** `/api/seo-report`
 
 
 
18
 
19
- **Parameters:**
20
- - `domain`: The URL to scrape (e.g., `https://www.google.com`)
21
- - `limit`: Max pages to scan (default: 25)
 
22
 
23
- **Example:**
24
- https://ubuntu593-alt-scraper-api.hf.space/api/seo-report?domain=https://www.google.com&limit=5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Alt Scraper API
3
  emoji: 🕷️
4
  colorFrom: purple
5
  colorTo: blue
 
10
 
11
  # Alt Scraper API
12
 
13
+ A robust SEO scraping API built with FastAPI, Playwright, and advanced anti-bot bypass. Deployable on Hugging Face Spaces.
14
 
15
+ ## 🚀 Quick Start
16
 
17
+ ### Health Check
18
+ ```
19
+ GET https://ubuntu593-alt-scraper-api.hf.space/health
20
+ ```
21
 
22
+ ### Start a Scan
23
+ ```
24
+ POST https://ubuntu593-alt-scraper-api.hf.space/api/scanstart?domain=https://example.com&limit=25
25
+ ```
26
 
27
+ Or with JSON body:
28
+ ```bash
29
+ curl -X POST "https://ubuntu593-alt-scraper-api.hf.space/api/scanstart" \
30
+ -H "Content-Type: application/json" \
31
+ -d '{"domain": "https://example.com", "limit": 25}'
32
+ ```
33
+
34
+ **Response**: `{"job_id": "abc-123..."}`
35
+
36
+ ### Check Progress
37
+ ```
38
+ GET https://ubuntu593-alt-scraper-api.hf.space/api/progress?job_id=YOUR_JOB_ID
39
+ ```
40
+
41
+ ### Get Results
42
+ ```
43
+ GET https://ubuntu593-alt-scraper-api.hf.space/api/result?job_id=YOUR_JOB_ID
44
+ ```
45
+
46
+ ## 📋 Complete API Reference
47
+
48
+ See [COMPLETE_API_REFERENCE.md](./COMPLETE_API_REFERENCE.md) for full documentation.
49
+
50
+ ## 🔧 Features
51
+
52
+ - **Tiered Fetching Strategy**: curl_cffi → cloudscraper → Playwright
53
+ - **Anti-Bot Bypass**: Playwright Stealth mode with countermeasures
54
+ - **Real-time Progress**: WebSocket-like progress tracking
55
+ - **Async Processing**: Background job queue with FastAPI
56
+ - **Comprehensive Analysis**: Image ALT text, quality checks, and more
57
+
58
+ ## 🛠️ Endpoints
59
+
60
+ | Endpoint | Method | Description |
61
+ |----------|--------|-------------|
62
+ | `/health` | GET | System health check |
63
+ | `/api/status` | GET | Server status & connectivity |
64
+ | `/api/scanstart` | POST | Start new scan job |
65
+ | `/api/progress` | GET | Check scan progress |
66
+ | `/api/result` | GET | Get scan results |
67
+
68
+ ## 📦 Deployment
69
+
70
+ This app uses Docker and is configured for Hugging Face Spaces.
71
+
72
+ **Requirements**:
73
+ - Python 3.10+
74
+ - Playwright browsers
75
+ - FastAPI + Uvicorn
76
+
77
+ See [Dockerfile](./Dockerfile) for deployment configuration.
verify_hf_deployment.py ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import time
3
+ import json
4
+
5
+ print("=" * 60)
6
+ print("🚀 HUGGING FACE DEPLOYMENT VERIFICATION")
7
+ print("=" * 60)
8
+ print()
9
+
10
+ BASE_URL = "https://ubuntu593-alt-scraper-api.hf.space"
11
+
12
+ # Test 1: Health Check
13
+ print("Test 1: Health Check")
14
+ print(f"URL: {BASE_URL}/health")
15
+ try:
16
+ r = requests.get(f"{BASE_URL}/health", timeout=10)
17
+ print(f"Status: {r.status_code}")
18
+ print(f"Response: {r.text}")
19
+ if r.status_code == 200:
20
+ print("✅ PASSED")
21
+ else:
22
+ print("❌ FAILED")
23
+ except Exception as e:
24
+ print(f"❌ ERROR: {e}")
25
+ print()
26
+
27
+ # Test 2: System Status
28
+ print("Test 2: System Status")
29
+ print(f"URL: {BASE_URL}/api/status")
30
+ try:
31
+ r = requests.get(f"{BASE_URL}/api/status", timeout=10)
32
+ print(f"Status: {r.status_code}")
33
+ if r.status_code == 200:
34
+ print(f"Response: {json.dumps(r.json(), indent=2)}")
35
+ print("✅ PASSED")
36
+ else:
37
+ print(f"Response: {r.text[:200]}")
38
+ print("❌ FAILED")
39
+ except Exception as e:
40
+ print(f"❌ ERROR: {e}")
41
+ print()
42
+
43
+ # Test 3: Start Scan (Query Params)
44
+ print("Test 3: Start Scan (Query Parameters)")
45
+ print(f"URL: {BASE_URL}/api/scanstart?domain=https://example.com&limit=3")
46
+ try:
47
+ r = requests.post(f"{BASE_URL}/api/scanstart?domain=https://example.com&limit=3", timeout=10)
48
+ print(f"Status: {r.status_code}")
49
+ if r.status_code == 200:
50
+ response = r.json()
51
+ print(f"Response: {json.dumps(response, indent=2)}")
52
+ print("✅ PASSED")
53
+ job_id = response.get("job_id")
54
+
55
+ if job_id:
56
+ # Test 4: Check Progress
57
+ print()
58
+ print("Test 4: Check Progress")
59
+ print(f"URL: {BASE_URL}/api/progress?job_id={job_id}")
60
+ time.sleep(2) # Wait a bit
61
+ r2 = requests.get(f"{BASE_URL}/api/progress?job_id={job_id}", timeout=10)
62
+ print(f"Status: {r2.status_code}")
63
+ if r2.status_code == 200:
64
+ print(f"Response: {json.dumps(r2.json(), indent=2)}")
65
+ print("✅ PASSED")
66
+ else:
67
+ print(f"Response: {r2.text[:200]}")
68
+ print("❌ FAILED")
69
+ else:
70
+ print(f"Response: {r.text[:300]}")
71
+ print("❌ FAILED - This is the issue you're seeing!")
72
+ print()
73
+ print("💡 SOLUTION:")
74
+ print("1. Go to: https://huggingface.co/spaces/ubuntu593/alt-scraper-api/settings")
75
+ print("2. Scroll down to find 'Factory Reboot' button")
76
+ print("3. Click it and wait 3-5 minutes for rebuild")
77
+ print("4. Run this script again")
78
+ except Exception as e:
79
+ print(f"❌ ERROR: {e}")
80
+ print()
81
+
82
+ # Test 5: Start Scan (JSON Body)
83
+ print("Test 5: Start Scan (JSON Body)")
84
+ print(f"URL: {BASE_URL}/api/scanstart")
85
+ try:
86
+ r = requests.post(
87
+ f"{BASE_URL}/api/scanstart",
88
+ json={"domain": "https://example.com", "limit": 3},
89
+ timeout=10
90
+ )
91
+ print(f"Status: {r.status_code}")
92
+ if r.status_code == 200:
93
+ print(f"Response: {json.dumps(r.json(), indent=2)}")
94
+ print("✅ PASSED")
95
+ else:
96
+ print(f"Response: {r.text[:200]}")
97
+ print("❌ FAILED")
98
+ except Exception as e:
99
+ print(f"❌ ERROR: {e}")
100
+ print()
101
+
102
+ print("=" * 60)
103
+ print("VERIFICATION COMPLETE")
104
+ print("=" * 60)
105
+ print()
106
+ print("If you see 404 errors above:")
107
+ print("→ Your HF Space needs to rebuild with latest code")
108
+ print("→ Follow the solution steps shown above")
109
+ print()
110
+ print("If all tests pass:")
111
+ print("→ Your deployment is working perfectly! ✅")