import socket my_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # use the host and port where your web server is running my_socket.connect(('127.0.0.1', 8080)) cmd = 'GET http://127.0.0.1/robot.txt HTTP/1.0\r\n\r\n'.encode() my_socket.send(cmd) while True: data = my_socket.recv(512) if len(data) < 1: break print(data.decode(), end='') my_socket.close()