def pretty_url(line): for scheme, host, path, query in RE_URL.findall(line): scheme = scheme or "http://" host = host.decode("idna") path = decode(urllib.unquote(path)) or "" query = decode(urllib.unquote(query)) or "" return u"".join([scheme, host, path, query])
def pretty_url(line): for scheme, host, path, query in RE_URL.findall(line): scheme = scheme or 'http://' host = host.decode('idna') path = decode(urllib.unquote(path)) or '' query = decode(urllib.unquote(query)) or '' return u''.join([scheme, host, path, query])
def sit(item, name): try: htmlstring = urllib.urlopen('http://www.sit.no/content.ap?thisId=%s' % item).read() root = fromstring(decode(htmlstring)) except IOError, e: return '%s: %s' % (name, e)