Задать вопрос

Тел: +7 965 3737 888

430

Просмотров

4

Ответов

nofollow filter

This filter add extra attribute rel="nofollow" to any "<a ..." element in the value, which does not contain it already. I use this to filter comments text in my blog.

Вопрос полезен? Да0/Нет0
file_3347.py(255.0б)
None

Ответы (4):

Ответmuhuk:09.04.2009
Ответ полезен? Да0/Нет0

building on muffinresearch's regex:

<a (?![^>]*rel=["\']nofollow[\'"])(?=[^>]*href=["\']http)

This matches only internal links. (hopefully)

Ответmuffinresearch:03.07.2008
Ответ полезен? Да0/Нет0

One small issue with this is that the regex doesn't match when you just add the text "nofollow" somewhere in one of the links being tested e.g: an href with a fragment-identifier like so: "blah.com#nofollow"

The following regex prevents bypassing the filter in this way

re.compile('<a (?![^>]*rel=["\']nofollow[\'"])')

Ответluckystarr:07.09.2007
Ответ полезен? Да0/Нет0

@polarbear

This would not work. I doubt that Google interprets JavaScript to check if it may or may not contribute the current sites pagerank to a link.

Ответpolarbear:24.07.2007
Ответ полезен? Да0/Нет0

You can use also jQuery like:

$(".comment a").attr({rel: "nofollow"});

to add rel="nofollow" attribute to all a within class .comment