Make it work with a real URL
Closed this issue · 1 comments
Re-Issue an old issue from http://code.activestate.com/recipes/576918/
is there a way to make it work with a url? i can shorten integers all day long, but when i actually enter a url i get this:
>> import short_url >> link = '/home/gmilby/public_html/syrbotwebdesign.com/scripts/playground' >> url = short_url.encode_url(link) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "short_url.py", line 66, in encode_url return DEFAULT_ENCODER.encode_url(n, min_length) File "short_url.py", line 15, in encode_url return self.enbase(self.encode(n), min_length) File "short_url.py", line 19, in encode return (n & ~self.mask) | self._encode(n & self.mask) TypeError: unsupported operand type(s) for &: 'str' and 'long'
i kept shaving off the beginning (http:, then // then...) same error everytime.
is there a way to short a real URL? (Protocoll://hostname:port/path) not only Integer values, if not the package name is misleading.
@loechel the way that package works is different, nothing is wrong with its name.
From its docstring/README:
The intended use is that incrementing, consecutive integers will be used as
keys to generate the short URLs. For example, when creating a new URL, the
unique integer ID assigned by a database could be used to generate the URL
by using this module. Or a simple counter may be used. As long as the same
integer is not used twice, the same short URL will not be generated twice.