Troubles debugging a script

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()

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Ah, sorry, I didn’t know :confused: Thank you so much! I’ll do it next time!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.