473,778 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Looking for Python code to obsfucate mailto links on web site

I'm looking at putting some e-mail contact addresses on a web site, and
wanted to make it difficult for spammers to harvest them.

I found some Python code that I can call within my application.

http://www.zapyon.de/spam-me-not/

It works exactly as expected. However, I am concerned that the technique
used for obsfucating the e-mail address may be a bit weak.

Searching the web it looks like the best solution for me might be to
embed JavaScript in the web page that dynamically generates the e-mail
address in the browser client.

I've found on-line tools that will generate suitable JavaScript, but
need to automate the "encoding" process in Python.

Now I could write suitable code myself, but would be surprised if it
wasn't already available. Any pointers?

To head of a few comments I'm anticipating ;-)
- no I don't want to use a contact form
- accessibility is an issue, but I'm also including postal addresses and
phone numbers giving alternatives to e-mail. Also the main enquiry
address won't be obfuscated.
Jun 25 '06 #1
3 1897
On Sun, 25 Jun 2006 21:10:31 +0100,
Andrew McLean <an*********@an dros.org.uk> wrote:
I'm looking at putting some e-mail contact addresses on a web site,
and wanted to make it difficult for spammers to harvest them.
[ ... ]
Searching the web it looks like the best solution for me might be to
embed JavaScript in the web page that dynamically generates the e-mail
address in the browser client.
[ ... ]
Now I could write suitable code myself, but would be surprised if it
wasn't already available. Any pointers?


Pointers? What do you think this is, C? ;-) Try this:

def spam_averse_ema il_address( email_address, text ):
"""return HTML-embedded javascript to create a spam-averse mailto link"""

def char_codes( a_string ):
return ",".join(str(or d(a_char)) for a_char in a_string)

return """<script type="text/javascript">
<!--
document.write(
'<a href="mailto:'
+ String.fromChar Code(%s)
+ '">'
+ String.fromChar Code(%s)
+ '<\/A>');
// -->
</script>""" % (char_codes(ema il_address), char_codes(text ))

The newlines within the triple quoted string are important; use that
function something like this:

print "<html>"
print "<head><title>T itle</title></head>
print "<body>
print "<P>%s</P>" % spam_averse_ema il_address( 'e****@mydomain .com',
'click here to email me' )
print "</body>"
print "</html>"

You mentioned accessibility; make sure that your HTML does something
sensible if the user's browser doesn't do javascript.

HTH,
Dan

--
Dan Sommers
<http://www.tombstoneze ro.net/dan/>
"I wish people would die in alphabetical order." -- My wife, the genealogist
Jun 25 '06 #2
Dan Sommers wrote:
On Sun, 25 Jun 2006 21:10:31 +0100,
Andrew McLean <an*********@an dros.org.uk> wrote:

I'm looking at putting some e-mail contact addresses on a web site,
and wanted to make it difficult for spammers to harvest them.

[ ... ]

Searching the web it looks like the best solution for me might be to
embed JavaScript in the web page that dynamically generates the e-mail
address in the browser client.

[ ... ]

Now I could write suitable code myself, but would be surprised if it
wasn't already available. Any pointers?

Pointers? What do you think this is, C? ;-) Try this:

def spam_averse_ema il_address( email_address, text ):
"""return HTML-embedded javascript to create a spam-averse mailto link"""

def char_codes( a_string ):
return ",".join(str(or d(a_char)) for a_char in a_string)

return """<script type="text/javascript">
<!--
document.write(
'<a href="mailto:'
+ String.fromChar Code(%s)
+ '">'
+ String.fromChar Code(%s)
+ '<\/A>');
// -->
</script>""" % (char_codes(ema il_address), char_codes(text ))

The newlines within the triple quoted string are important; use that
function something like this:

print "<html>"
print "<head><title>T itle</title></head>
print "<body>
print "<P>%s</P>" % spam_averse_ema il_address( 'e****@mydomain .com',
'click here to email me' )
print "</body>"
print "</html>"

You mentioned accessibility; make sure that your HTML does something
sensible if the user's browser doesn't do javascript.

HTH,
Dan


Bruno Desthuilliers has a nice one-liner:

python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom. gro'.split('@')])"
I came up with this:

python <<EOF
print "".join([chr(ord(i)^ord( j)^64) for (i,j) in
zip('hpqudxu',' BCEGKMQ')] +
list('ude.alcu. ibm@'[::-1]))
EOF

For mine, you you'll have to reverse the algorithm to generate the
"cipher text".

James

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
Jun 26 '06 #3
Dan Sommers wrote:
On Sun, 25 Jun 2006 21:10:31 +0100,
Andrew McLean <an*********@an dros.org.uk> wrote:
I'm looking at putting some e-mail contact addresses on a web site,
and wanted to make it difficult for spammers to harvest them.


[ ... ]
Searching the web it looks like the best solution for me might be to
embed JavaScript in the web page that dynamically generates the e-mail
address in the browser client.


[ ... ]
Now I could write suitable code myself, but would be surprised if it
wasn't already available. Any pointers?


Pointers? What do you think this is, C? ;-) Try this:

def spam_averse_ema il_address( email_address, text ):
"""return HTML-embedded javascript to create a spam-averse mailto link"""

def char_codes( a_string ):
return ",".join(str(or d(a_char)) for a_char in a_string)

return """<script type="text/javascript">
<!--
document.write(
'<a href="mailto:'
+ String.fromChar Code(%s)
+ '">'
+ String.fromChar Code(%s)
+ '<\/A>');
// -->
</script>""" % (char_codes(ema il_address), char_codes(text ))

The newlines within the triple quoted string are important; use that
function something like this:

print "<html>"
print "<head><title>T itle</title></head>
print "<body>
print "<P>%s</P>" % spam_averse_ema il_address( 'e****@mydomain .com',
'click here to email me' )
print "</body>"
print "</html>"

You mentioned accessibility; make sure that your HTML does something
sensible if the user's browser doesn't do javascript.

HTH,
Dan


That's great. Just what I was looking for.

Jun 27 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3849
by: Logan | last post by:
Several people asked me for the following HOWTO, so I decided to post it here (though it is still very 'alpha' and might contain many (?) mistakes; didn't test what I wrote, but wrote it - more or less - during my own installation of Python 2.3 on Fedora Core 1 Linux for a friend of mine). Anyway, HTH, L.
2
2276
by: McGoo | last post by:
Hello group, I would appreciate some help with this. My webpage is in a frame, and holds a lot of images. Some of these images have links and use Javascript to carry out a mailto operation. When OE is launched, the loading of the page stops, but it will not resume loading after OE is closed - a 'refresh' would work in effect. I tried to reopen the window, but it anchors at the top. Is there some expression or approach I am completely...
14
6905
by: Akseli Mäki | last post by:
Hi, Hopefully this is not too much offtopic. I'm working on a FAQ. I want to make two versions of it, plain text and HTML. I'm looking for a tool that will make a plain text doc out of the HTML doc. The HTML version doesn't have anything fancy, just internal links. So the tool must be able to delete internal links and anchors from the HTML version, but leave external links in simplified form. That is, the HTML version would say <a...
12
5578
by: catyionic | last post by:
hi, Due to trying many different form options, with none of them working, I opted for this to receive info back from this site: http:\\www.elderslastwish.com <form name="feedback_form" method="post" action="mailto:mymail@yahoo.com?subject=Elder's Last Wish Application Form" enctype="text/plain">
13
7098
by: John Baker | last post by:
HI; Quick question: How do I specify an email subject when using the setup <a href="mailto:dogs@cats.com">Mail to the cat</a> Can someone show me how it would look if the subject was "mice"? Thanks a lot
3
1694
by: muttu2244 | last post by:
Hi all, Am trying to read a email ids which will be in the form of links ( on which if we click, they will redirect to outlook with their respective email ids). And these links are in the HTTPS page, a secured http page. The point is that am able to read some links with HTTP page, but am not able to read the same when I try with HTTPS.
52
3625
by: Steve Holden | last post by:
I've been thinking (and blogging) about python evangelism since PyCon, as a result of which I created a squidoo lens: http://www.squidoo.com/pythonlogy Imagine my surprise at discovering that this has gone up in rank (by number of views) from # 442,000 or so to #153! Clearly there's some mileage in marketing Python, and I'd like to keep the buzz going if it means more people will adopt the language.
0
285
by: Cameron Laird | last post by:
QOTW: "Generally, you should always go for whatever is clearest/most easily read (not just in Python, but in all languages)." - Timothy Delaney "You will find as your programming experience increases that the different languages you learn are appropriate for different purposes, and have different advantages and disadvantages. Python excels at expressing algorithms in an unambiguous and easily-readable way." - Steve Holden Is Python...
34
2928
by: nicolasfr | last post by:
Hi, I am a bit disapointed with the current Python online documentation. I have read many messages of people complaining about the documentation, it's lack of examples and the use of complicated sentences that you need to read 10 times before understanding what it means. That's why I have started a collaborative project to make a user contributed Python documentation. The wiki is online here: http://www.pythondocs.info
0
9629
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8957
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7475
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5500
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4033
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2865
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.