Monday, January 12, 2009

Convert Character Code to HTML Entity code in Python

To hide for particular link to avoid from detected, we could use various of way to encode code. In Javascript, we can use String.fromCharCode() method used to decode unicode of the particular website link. Example for www.google.com
  1. document.write(String.fromCharCode(119,119,119,46,103,111,111,103,108,101,46,99,111,109));
result: www.google.com

How we going to get unicode for www.google.com in Python?

For python, ord() function is used as follow.

import sys

st = sys.argv[1]
e = []
for a in st:
e.append("%s" %ord(a))

print ",".join(e)

Result:

0 comments: