Advertisement
Sergio_Istea

error_codes.py

Jun 15th, 2023
980
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. import subprocess
  2.  
  3. def get_http_error_code(url):
  4.     try:
  5.         output = subprocess.check_output(['curl', '-I', '-s', '-o', '/dev/null', '-w', '%{http_code}', url])
  6.         return int(output.strip())
  7.     except subprocess.CalledProcessError as e:
  8.         # Error al ejecutar el comando curl
  9.         print(f"Error: {e}")
  10.         return None
  11.  
  12.  
  13. codes = {
  14.  
  15.         "200" : "request succeeded.",
  16.         "404" : "not found.",
  17.         "503" : "unavailable."
  18.  
  19.         }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement