[Python] http request to google returning empty python socket

Discussão em 'Python' iniciado por Stack, Março 16, 2025.

  1. Stack

    Stack Membro Participativo

    im trying to send an http request to google, but all I receive is empty (b""). Here is my code:

    import socket

    target_host = "www.google.com"

    target_port = 80
    client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    client.connect((target_host, target_port))
    print("Connected...")


    request = "GET / HTTP/1.1\r\nHost:%s\r\n\r\n" % target_host

    response = client.recv(4096)
    http_response = repr(response)
    http_response_len = len(http_response)

    print("[+RECV+] - length %d" % http_response_len)
    print(http_response)


    Here is my response:

    [+RECV+] - length 3
    b''


    (also it took like 240 seconds to complete the request, is that normal?) Thanks!

    Continue reading...

Compartilhe esta Página