Hello! I’m a newbie and I’m having my time to debug my scripts… sigh. I am following the Python for everybody course and now I’m stuck at chapter 12, trying to write a basic script to scrap web pages… but yeah, not working -_-
I attached my code here, hoping for somebody to highlight what kind of fricking error I’m doing. Thank you so much!
import urllib.request, urllib.parse, urllib.error
try:
HOST = input('Internet address: ')
HOST.lower()
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect((HOST, 80))
cmd = ('GET ' + HOST + ' HTTP/1.0\r\n\r\n').encode()
# cmd = ('GET '+ HOST + ' HTTP/1.0\r\n\r\n').encode()
mysock.send(cmd)
while True:
data = mysock.recv(512)
if len(data) < 1:
break
print(data.decode(),end='')
mysock.close()
except:
print('Wrong address!')
exit()