import requests

query = "OpenAI GPT-5"
url = "http://search.severijnse.eu/search"

params = {
    "q": query,
    "tbm": "web",
    "num": 5,
    "safe": "off",
    "format": "json"
}

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
}

response = requests.get(url, params=params, headers=headers)

if response.status_code == 200:
    try:
        data = response.json()
        if "results" in data:
            for result in data["results"]:
                print(result["title"], "-", result["url"])
        else:
            print("No results key in JSON. The instance may restrict API access.")
    except Exception as e:
        print("Error parsing JSON:", e)
else:
    print("Request failed with status:", response.status_code)

