coding utf-8 from PluginBase import PluginBase def html_tags source ta

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- coding: utf-8 -*-
from PluginBase import PluginBase
def html_tags(source):
tags = {
u'"' : u'"',
u'<br>' : 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('<div>', citata)
citata_end = body.find('</div>', vote_end)
return html_tags(body[vote_end + 5 : citata_end].decode('cp1251'))