def get(addr, args={},  headers={}, version='HTTP/1.1', auth=()):

    """
    It does an http/https request.
    """

    addr    = addr.strip().rstrip()
    url     = urlparse(addr)
    default = {
    'user-agent':'Websnake/1.0.0', 
    'accept-charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
    'connection':'close',
    'host': url.hostname}

    default.update(headers)
    args = '?%s' % urlencode(args) if args else ''

    if auth: default['authorization'] = build_auth(*auth)

    data = 'GET %s%s %s\r\n' % (url.path + ('?' + url.query if \
    url.query else ''), args, version)
    data = data + build_headers(default)
    port = url.port if url.port else getservbyname(url.scheme)
    data = data.encode('utf8')

    return create_con_ssl(url.hostname, port, data) \
    if url.scheme == 'https' else create_con(url.hostname, port, data)
def get ( addr , args = { } , headers = { } , version = 'HTTP/1.1' , auth = ( ) ) : addr = addr . strip ( ) . rstrip ( ) url = urlparse ( addr ) default = { 'user-agent' : 'Websnake/1.0.0' , 'accept-charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.7' , 'connection' : 'close' , 'host' : url . hostname } default . update ( headers ) args = '?%s' % urlencode ( args ) if args else '' if auth : default [ 'authorization' ] = build_auth ( * auth ) data = 'GET %s%s %s\r\n' % ( url . path + ( '?' + url . query if url . query else '' ) , args , version ) data = data + build_headers ( default ) port = url . port if url . port else getservbyname ( url . scheme ) data = data . encode ( 'utf8' ) return create_con_ssl ( url . hostname , port , data ) if url . scheme == 'https' else create_con ( url . hostname , port , data )
It does an http/https request.