import requests
import json

def explore_api_endpoints():
    """探索服务器上可用的API端点"""
    
    base_url = "http://192.168.3.143:5500"
    
    # 常见的API路径模式
    possible_paths = [
        "/",
        "/api",
        "/api/",
        "/api/data-parse",
        "/api/data-parse/",
        "/health",
        "/status",
        "/docs",
        "/swagger",
        "/openapi",
        "/process-urls",
        "/api/process-urls",
        "/data-parse/process-urls",
        "/api/data-parse/process-urls"
    ]
    
    print(f"正在探索服务器: {base_url}")
    print("=" * 60)
    
    for path in possible_paths:
        url = base_url + path
        try:
            print(f"\n🔍 测试路径: {path}")
            
            # 尝试GET请求
            try:
                response = requests.get(url, timeout=10)
                print(f"  GET {path} -> 状态码: {response.status_code}")
                if response.status_code == 200:
                    print(f"  响应内容: {response.text[:200]}...")
            except Exception as e:
                print(f"  GET {path} -> 错误: {e}")
            
            # 尝试POST请求（对于process-urls接口）
            if "process-urls" in path:
                try:
                    test_data = {"urlArr": ["https://example.com"]}
                    response = requests.post(
                        url, 
                        json=test_data, 
                        headers={"Content-Type": "application/json"},
                        timeout=10
                    )
                    print(f"  POST {path} -> 状态码: {response.status_code}")
                    if response.status_code != 404:
                        print(f"  响应内容: {response.text[:200]}...")
                except Exception as e:
                    print(f"  POST {path} -> 错误: {e}")
                    
        except Exception as e:
            print(f"  ❌ 测试失败: {e}")
    
    print("\n" + "=" * 60)
    print("探索完成!")

if __name__ == "__main__":
    explore_api_endpoints() 