From: Oleg Broytman Date: Sat, 17 Nov 2007 22:19:31 +0000 (+0000) Subject: Replace spaces with underscores for Wikipedia. X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=f95ee475c554f22998041186e5daf26872fa8b69;hp=49891ef00be55498d99a740a7d3b992e5971625b;p=phdru.name%2Fphdru.name.git Replace spaces with underscores for Wikipedia. Quote spaces with %20 instead of +. git-svn-id: file:///home/phd/archive/SVN/phdru.name/scripts@72 7bb0bf08-9e0d-0410-b083-99cee3bf18b8 --- diff --git a/phd_pp.py b/phd_pp.py index 64df519..b3ad03a 100644 --- a/phd_pp.py +++ b/phd_pp.py @@ -99,11 +99,11 @@ class phd_pp(Template): return "http://www.yandex.ru/yandsearch?text=%s&rpt=rad" % quote_string(query, "cp1251") def wikipedia(self, query): - return "http://en.wikipedia.org/wiki/%s" % quote_string(query) + return "http://en.wikipedia.org/wiki/%s" % quote_string(query.replace(' ', '_')) def wikipedia_ru(self, query): - return "http://ru.wikipedia.org/wiki/%s" % quote_string(query) + return "http://ru.wikipedia.org/wiki/%s" % quote_string(query.replace(' ', '_')) def quote_string(s, to_encoding="utf-8"): - return urllib.quote_plus(unicode(s, "koi8-r").encode(to_encoding)) + return urllib.quote(unicode(s, "koi8-r").encode(to_encoding))