Advertisement
kwabenasapong

Untitled

Dec 16th, 2022
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. #!/usr/bin/python3
  2. """
  3. Module for fetching the status of https://alx-intranet.hbtn.io/status
  4. """
  5.  
  6. import urllib.request
  7.  
  8. def get_status():
  9.     """
  10.    Fetches the status of https://alx-intranet.hbtn.io/status
  11.    and returns the body of the response as a bytes object
  12.    """
  13.     with urllib.request.urlopen('https://alx-intranet.hbtn.io/status') as response:
  14.         return response.read()
  15.  
  16. if __name__ == "__main__":
  17.     # Get the status and print the body of the response
  18.     status = get_status()
  19.     print("Body response:")
  20.     print("\t- type:", type(status))
  21.     print("\t- content:", status)
  22.     print("\t- utf8 content:", status.decode('utf-8'))
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement