Mostrando entradas con la etiqueta Url. Mostrar todas las entradas
Mostrando entradas con la etiqueta Url. Mostrar todas las entradas

[Python] Goo - Acorta tu URL

d
Autor: @The_Swash
Descripción : Un acortador de url que la obtiene de goo.gl

#----------------------------------------------------------
# Obtener URL acortada mediante http://goo.gl
# Programador: The Swash
# Agradecimientos: Psymera, 11Sep, [Zero] y todo h-sec
# Website: http://h-sec.org
#----------------------------------------------------------
 
import socket, urllib, re
def GetGooURL(url):
    header = ['POST /api/shorten HTTP/1.1\r\n',
              'Host: goo.gl\r\n',
              'Content-Type: application/x-www-form-urlencoded;charset=utf-8\r\n',
              'Content-Length: 41\r\n',
              'Connection: close\r\n\r\n',
              'URLENCODE']
    if re.match('^http://', url):
        url2 = url
    else:
        url2 = 'http://' + url
    address = socket.gethostbyname('goo.gl')
    link = urllib.urlencode({'url':url2})
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    header[5] = link + '&security_token\r\n'
    length = len(header)
    try:
        sock.connect((address,80))
        for i in range(length):
            sock.send(header[i])
        buff = sock.recv(1024)
    except:
        return 'Error de conexion'
     
    sock.close()
    data = re.findall('Location: (.+)\r\n', buff)
    return data[0]
 
url = GetGooURL('h-sec.org')
print url
raw_input()
Leer más...

URL Shortner

d
Autor: Jorge Pizarro Callejas
Descripcion: Script que permite acortar una URL.
Funcionamiento: ./urlshortener (url para acortar)
#!/bin/sh
#Script programado por Jorge Pizarro Callejas (aka Jorgicio)
#Envíen sus correcciones a [jpizarro@inf.utfsm.cl]

#Donde url es el parámetro, la url que quieres acortar
#Verifiquemos si tienes curl
whereis curl
if [ $? == 1 ];then
    echo "Necesitas curl para que funcione. Instálalo con tu gestor de paquetes favorito."
else
    #Verifiquemos si tienes html2text
    whereis html2text
    if [ $? == 1 ];then
        echo "Necesitas html2text para que funcione. Instálalo con tu gestor de paquetes favorito."
    else
        curl -s -A Mozilla 'http://3.ly/?bm=1&u='$1 | html2text | grep ready
    fi
fi
Leer más...