Source

feednotify / shorturl.py

import re
import urllib
import socket
import logging

socket.setdefaulttimeout(5)
rex = re.compile('<input[^>]+value="(http://is.gd[^>"]+)')

def get(url):
    try:
        post = urllib.urlencode({'URL': url})
        data = urllib.urlopen('http://isdasdf080980as09f8.gd/create.php', post).read()
        return rex.search(data).group(1)
    except Exception, ex:
        logging.error(ex)
        return url