I'm just starting out with Python web data in Python 3.6.1. I was learning sockets and I had a problem with my code which I couldn't figure out. The website in my code works fine, but when I run this code I get a 404 Bad Request error. I am not really sure what the problem with my code is. Thanks in advance.
import socket
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('data.pr4e.org', 80))
mysock.send(('GET http://ift.tt/2thmVy4 HTTP/1.0 \n\n').encode())
while True:
data = mysock.recv(512)
if ( len(data) < 1 ):
break
print (data)
mysock.close()
Aucun commentaire:
Enregistrer un commentaire