| import requests |
| import json |
| import time |
|
|
| API_URL = "https://ubuntu593-alt-scraper-api.hf.space/api/seo-report" |
|
|
| DOMAINS_TO_TEST = [ |
| {"url": "https://www.example.com", "limit": 1, "desc": "Simple Static Site"}, |
| {"url": "https://www.google.com", "limit": 1, "desc": "Big Tech (High Robustness)"}, |
| {"url": "https://www.wikipedia.org", "limit": 2, "desc": "Content Heavy"}, |
| {"url": "https://www.amazon.in", "limit": 1, "desc": "Anti-Bot Heavy (Amazon)"}, |
| ] |
|
|
| def run_tests(): |
| print(f"Starting Live API Tests against: {API_URL}\n") |
| print("-" * 60) |
| |
| results = [] |
|
|
| for item in DOMAINS_TO_TEST: |
| domain = item['url'] |
| limit = item['limit'] |
| desc = item['desc'] |
| |
| print(f"Testing: {domain} ({desc})...", end=" ", flush=True) |
| |
| start_time = time.time() |
| try: |
| |
| payload = {"domain": domain, "limit": limit} |
| response = requests.post(API_URL, json=payload, timeout=60) |
| |
| elapsed = time.time() - start_time |
| |
| if response.status_code == 200: |
| data = response.json() |
| summary = data.get('summary', {}) |
| discovered = summary.get('total_pages_discovered', 0) |
| images = summary.get('total_images_found', 0) |
| |
| print(f"SUCCESS ({elapsed:.2f}s)") |
| print(f" -> Pages Scanned: {summary.get('total_pages_scanned')}") |
| print(f" -> Images Found: {images}") |
| print(f" -> Details: {summary}") |
| results.append({"domain": domain, "status": "PASS", "time": elapsed, "data": summary}) |
| else: |
| print(f"FAILED ({response.status_code})") |
| print(f" -> Response: {response.text[:200]}") |
| results.append({"domain": domain, "status": "FAIL", "code": response.status_code}) |
| |
| except Exception as e: |
| print(f"ERROR: {str(e)}") |
| results.append({"domain": domain, "status": "ERROR", "error": str(e)}) |
| |
| print("-" * 60) |
|
|
| |
| print("\nTEST SUMMARY") |
| print("=" * 60) |
| for res in results: |
| status_icon = "[PASS]" if res['status'] == "PASS" else "[FAIL]" |
| print(f"{status_icon} {res['domain']:<30} | {res['status']}") |
| print("=" * 60) |
|
|
| if __name__ == "__main__": |
| run_tests() |
|
|