Guest User

Untitled

a guest
Jan 20th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. import socket
  2. import ssl
  3.  
  4. def main():
  5. host = 'www.google.com'
  6. port = 443
  7. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  8. context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
  9. wrapped_s = context.wrap_socket(s, server_hostname=host)
  10. wrapped_s.connect((host,port))
  11. message = "HEAD / HTTP/1.1rnrn"
  12. wrapped_s.sendall(str.encode(message))
  13. print(bytes.decode(wrapped_s.recv(4096)))
  14. s.close()
  15.  
  16.  
  17. if __name__ == "__main__":
  18. main()
  19.  
  20. HTTP/1.1 302 Found
  21. Cache-Control: private
  22. Content-Type: text/html; charset=UTF-8
  23. Referrer-Policy: no-referrer
  24. Location: https://www.google.ca/?gfe_rd=cr&dcr=0&ei=a_5jWryGCtPM8geM55pA
  25. Content-Length: 267
  26. Date: Sun, 21 Jan 2018 02:43:55 GMT
  27. Alt-Svc: hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35"
  28.  
  29. host = "https://www.google.ca/?gfe_rd=cr&dcr=0&ei=a_5jWryGCtPM8geM55pA"
  30.  
  31. socket.gaierror: [Errno 11001] getaddrinfo failed
Add Comment
Please, Sign In to add comment