Python sockets not responsered
Question: my code send a http request using sockets and then save the response.It works
for me yesterday, but today i cant receive response. I need to use sockets not
httplib or urllib. I dont know if code is not working or my python install is
crazy. thanks!

    
    
    import socket
    import logging
    
    
    def get_http(target, port, request):
        """
         Method that sends an HTTP request and returns the response
    
        :param target:
        :type target:
    
        :return:
        :rtype: str
        """
        try:
            s = socket.create_connection((target, port))
            s.sendall(request.encode())
            response = repr(s.recv(2024).decode())
        except socket.error as e:
            logging.error('Failed to create connection: %s', e.strerror)
        return response
    

* * *
    
    
    import lib.netgrab as n
    
    
    class Probe():
    
        def __init__(self):
            super(Probe, self).__init__()
    
        def prueba(self):
            n.get_http('www.website.com', 80, 'HEAD / HTTP/1.1\r\n\r\n')
    
    pr = Probe()
    re = pr.prueba()
    print(re)
    


Answer: You have forgot your return statement, please update:

    
    
    def prueba(self):
        return n.get_http('www.website.com', 80, 'HEAD / HTTP/1.1\r\n\r\n')
    

