Hex url coder
2017-01-14 20:02:45
import binascii
def hex_url(_url):
protocol = ''
filter = ['?', '=', "/"]
if _url.startswith('http://'):
protocol = 'http://'
_url = _url.replace(protocol, "")
if _url.startswith('https://'):
protocol = 'https://'
_url = _url.replace(protocol, "")
response = ""
for _c in _url:
if _c in filter:
response += _c
else:
response += str(binascii.hexlify(_c.encode('utf8'))).replace("b", "%").replace("'", "")
print(protocol + response)
hex_url("http://btbw.pl")
hex_url("http://www.blog.btbw.pl")
hex_url("http://bitbeecode.com")
hex_url("https://google.com")