Sign in

Check if a URL is reachable

There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.

Check if a URL is reachable.

import requests try: resp = requests.get(url, timeout=10) # 10 seconds timeout if resp.status_code != 200: msg = f"ERROR! This URL not reachable: {url}. Got status code: {resp.status_code}" else: msg = f"This URL is reachable: {url}" except Exception as e: msg = f"ERROR! This URL not reachable: {url}. Got exception {e}" print(msg)
copied