rjcostales

http_request.py

May 21st, 2022 (edited)
91
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. import requests
  3.  
  4. url = 'https://www.youtube.com'
  5. headers = {
  6.     "Connection": "keep-alive",
  7.     "User-Agent": "Mozilla/5.0",
  8.     "Accept": "image/jpg,image/*,*/*",
  9.     "Accept-Encoding": "gzip,deflate,br",
  10.     "Accept-Language": "en-US,en"
  11. }
  12.  
  13. response = requests.get(url, headers=headers)
  14.  
  15. print("-----response-----")
  16. print(url)
  17. print(response.status_code)
  18. print(response.elapsed)
  19.  
  20. headers = list(response.headers)
  21.  
  22. print("\n-----headers-----")
  23. list.sort(headers)
  24. for header in headers:
  25.      print(header, response.headers[header])
  26.  
  27. print("\n-----cookies-----")
  28. cookies = response.cookies
  29. for cookie in cookies:
  30.     print(cookie)
  31.  
RAW Paste Data Copied