import urllib.parse
import urllib.request
import json

api_key = "68f3c3689d0aa61d6e5e163b"
url = "https://api.scrapingdog.com/profile"

profile_ids = [
   # "sachin-gautam-9697a125b",
    "kaushik-rayamajhi-102269263",
   # "tinaw-h",
    #"anmol-bhusal",
]

for pid in profile_ids:
    params = {
        "api_key": api_key,
        "type": "profile",
        "id": pid,
        "premium": "true",
    }

    # Encode params and build full URL
    query_string = urllib.parse.urlencode(params)
    full_url = f"{url}?{query_string}"

    try:
        with urllib.request.urlopen(full_url) as response:
            if response.status == 200:
                data = response.read().decode("utf-8")
                json_data = json.loads(data)
                print(f"\n✅ Profile: {pid}")
                print(json.dumps(json_data, indent=2))
            else:
                print(f"❌ Failed to get {pid}, status code: {response.status}")
    except urllib.error.HTTPError as e:
        print(f"❌ HTTP Error for {pid}: {e.code} - {e.reason}")
    except urllib.error.URLError as e:
        print(f"❌ URL Error for {pid}: {e.reason}")

