Kwissle

My real-time quiz battle game Kwissle.com

Crosstips.org

My fun Crossword solver project. Crosstips.org & Krysstips.se

Kung Fu

Fujian White Crane Kung Fu

Photos

Photoalbum, both old and new.

Twitter

Follow me on Twitter

Contact me

My contact details and how to contact me.

 

KungFuPeople.com
Do you train Kung Fu?
Or know someone who does?
Then check out KungFuPeople.com


Mobile version of this page Mobile version of this page


 
Python

Control comment spam

http://www.peterbe.com/plog/add-hrefs-III

5th of April 2005

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 www.peterbe.com 
 and email mail@peterbe.com"""
)
 Visit <a href="http://www.peterbe.com">www.peterbe.com</a>
 and email <a href="mailto:mail@peterbe.com">mail@peterbe.com</a>

Then I saw this instruction on google.com 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__
 '0.7'
 >>> def nofollower(url):
 ...     template = '<a href="%s" rel="nofollow">%s'
 ...     return template % (url, url)
 ... 
 >>> print addhrefs("Visit www.peterbe.com", 
                    urllinkfunction=nofollower)
 Visit <a href="www.peterbe.com" rel="nofollow">www.peterbe.com

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 :)



Comment

MoWeBo - 11th November 2007  [«« Reply to this]
I see someting like this: <meta name="pagerank" content="7">
You can have a PR7?
 
Name:
Email:
hide my email address.

Your email address will be encoded to prevent email-extraction spiders from reading it so you won't get spammed if you decide to show your email address.