From the other posts on stack overflow this should be working
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connec
I am cleaning up the examples for Python 3. We need bytes/string conversion and we can also use automatic closing of the connection using with:
#!/usr/bin/env python3
import socket
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect(("example.com" , 80))
s.sendall(b"GET / HTTP/1.1\r\nHost: example.com\r\nAccept: text/html\r\n\r\n")
print(str(s.recv(4096), 'utf-8'))