Web Scraping with Python

I’m in a pickle, i was following a tutorial in [#py4e] and i cannot retrieve the data of the web page. Can someone help me and tell me what i did wrong?

import socket

mysock=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect((‘data.pr4e.org’, 80))
cmd=‘GET http://data.pr4e.org/romeo.txt HTTP/1.0\n\n’.encode()
mysock.send(cmd)

while True:
data=mysock.recv(512)
if (len(data)<1):
break
print(data.dencode())
mysock.close()

22.09.20 EX12-01 (2)

Please post your actual code instead of a picture. Thanks

1 Like