Little hack to make a bit harder for spammers to parse email address on the web.
def cryptEmailAddress(addr): r = [] for l in addr: r.append('&#%d;' % ord(l)) return string.join(r,'') >>>cryptEmailAddress('jkx@larsen-b.com') 'jkx@larse....'
And simply put this in a href mailto: and enjoy :) Check the article’s pages on this website for a example.
This is a sample post to show my email :=)
For even shorter code:
address="some@address.com"
print ”.join(["&#%d;" % ord(x) for x in address])
Yeah it’s shorter, in fact the topic is ‘Obscufated email’ not Obscufated Python :) .. But your version is easy to read too ..
– Happy obscufated ? :)
Ofcourse you could also do:
def cryptEmailAddress(addr):
return reduce(lambda a, b: “%s%d;”%(a, ord(b)), addr,”)
:)
Ofcourse you could also do:
sorry about the raw crap ;)
In fact, i’m working in a school, so I avoid this kind of stuf :)
– /join #perl-golf
and ofcourse if you look from the spamers point of view:
:D
this is a very old trick, and i’m sure all email address harvesters can already cope with this – it’s almost as simple as the AT/DOT crap
Oh, is it so easy to get on Python Daily? :-)
I’ve been using this hack (in its one-liner form) for a long time. ;)
So here’s another scrambler so that I get famous: :D
def nojs_scramble(address):
r = ”
for x in xrange(len(address)):
if x % 2 == 0:
r += address[x]
else:
r += ‘%d;’ % ord(address[x])
return r
def js_scramble(address):
r = “var s=”; “;
for x in xrange(0,len(address),2):
r += “s += ‘%s’; ” % address[x:x+2]
r += “document.write(s);”
return r
def scramble(address):
import random
v = {}
v['nojs'] = nojs_scramble(address)
v['js'] = js_scramble(address)
result = “”"
“”" % v
return result
print scramble(‘test@domain.com’)
This gives:
<script>
var s=”; s += ‘te’; s += ‘st’; s += ‘@d’; s += ‘om’; s += ‘ai’; s += ‘n.’; s += ‘co’; s += ‘m’; document.write(s);
</script>
<noscript>
test@domain.com
</noscript>
Oops, trouble with posting..
result = “”"
<script>
%(js)s
</script>
<noscript>
%(nojs)s
</noscript>
“”" % v
Hum .. little trick from Christian .. simply crypt the ‘mailto:’ too. This isn’t catholic, but it works too.
– Really enjoy this little hack
I put my e-mail address on the Web only in the form of a bitmap graphic. Humans can read it easily. In order to use it, they have to retype it; but my address is short and they’ll have to do much more typing if they want to send me any worthwhile message.