# -*- coding: utf-8 -*- from PluginBase import PluginBase def html_tags(source): tags = { u'"' : u'"', u'
' : u'\n' } for tag, tag_replace in tags.items(): source = source.replace(tag, tag_replace) return source class last_plugin(PluginBase): def process(self): if self.is_command == True: if self.command == u'баш': import urllib2 req = urllib2.Request('http://bash.org.ru') r = urllib2.urlopen(req) body = r.read() citata = body.find('div class="q"') vote_end = body.find('
', citata) citata_end = body.find('
', vote_end) return html_tags(body[vote_end + 5 : citata_end].decode('cp1251'))