Control comment spam

05 April 2005   1 comment   Python

Powered by Fusion×

Did you see my mentioning about addhrefs last week? addhrefs is a python module that turns a text full of URLs and email addresses into links. For example:

>>> from addhrefs import addhrefs
>>> print addhrefs("""Visit 
and email""")
Visit <a href=""></a>
and email <a href=""></a>

Then I saw this instruction on about Preventing comment spam They suggest you add a rel="nofollow" to links in your comments on your blog and with a bit of luck this will reduce the amount of comment spam you get on your blogs. So, how to do that?

All you need is some Python code and my addhrefs module installed. Since the 0.7 version you can pass it your own function that that turns urls into links. Let this example speak for itself:

>>> from addhrefs import addhrefs, __version__
>>> __version__
>>> def nofollower(url):
...     template = '<a href="%s" rel="nofollow">%s'
...     return template % (url, url)
>>> print addhrefs("Visit", 
Visit <a href="" rel="nofollow">

So now I hope Movable type, Worldpress and all those guys copy my code so I can get some credits for my work into this module :)


I see someting like this: <meta name="pagerank" content="7">
You can have a PR7?

Your email will never ever be published

Related posts

Python Cookbook arrived 05 April 2005
Your webpage in Lynx 08 April 2005
Related by keywords:
Add links to a text (take III) 22 March 2005
Add links to a text (take II) 10 November 2004