remove tostring() from Browser
This commit is contained in:
parent
ae34c7b088
commit
d16a44ffbd
2 changed files with 3 additions and 9 deletions
|
|
@ -46,7 +46,7 @@ class Comment(object):
|
||||||
self.author = sub.find('a').text
|
self.author = sub.find('a').text
|
||||||
self.date = self.parse_date(sub.find('i').tail)
|
self.date = self.parse_date(sub.find('i').tail)
|
||||||
self.score = int(sub.findall('i')[1].find('span').text)
|
self.score = int(sub.findall('i')[1].find('span').text)
|
||||||
self.body = self.browser.tostring(sub.find('p'))
|
self.body = self.browser.parser.tostring(sub.find('p'))
|
||||||
elif sub.attrib.get('class', '') == 'commentsul':
|
elif sub.attrib.get('class', '') == 'commentsul':
|
||||||
comment = Comment(self.browser, sub.find('li'), self.id)
|
comment = Comment(self.browser, sub.find('li'), self.id)
|
||||||
self.comments.append(comment)
|
self.comments.append(comment)
|
||||||
|
|
@ -88,7 +88,7 @@ class Article(object):
|
||||||
date_s = unicode(div.find('i').tail)
|
date_s = unicode(div.find('i').tail)
|
||||||
#print date_s
|
#print date_s
|
||||||
if div.attrib.get('class', '').startswith('bodydiv '):
|
if div.attrib.get('class', '').startswith('bodydiv '):
|
||||||
self.body = self.browser.tostring(div)
|
self.body = self.browser.parser.tostring(div)
|
||||||
|
|
||||||
def append_comment(self, comment):
|
def append_comment(self, comment):
|
||||||
self.comments.append(comment)
|
self.comments.append(comment)
|
||||||
|
|
@ -100,7 +100,7 @@ class Article(object):
|
||||||
yield c
|
yield c
|
||||||
|
|
||||||
def parse_part2(self, div):
|
def parse_part2(self, div):
|
||||||
self.part2 = self.browser.tostring(div)
|
self.part2 = self.browser.parser.tostring(div)
|
||||||
|
|
||||||
class ContentPage(DLFPPage):
|
class ContentPage(DLFPPage):
|
||||||
def on_loaded(self):
|
def on_loaded(self):
|
||||||
|
|
|
||||||
|
|
@ -249,12 +249,6 @@ class BaseBrowser(mechanize.Browser):
|
||||||
if self.__cookie:
|
if self.__cookie:
|
||||||
self.__cookie.save()
|
self.__cookie.save()
|
||||||
|
|
||||||
def tostring(self, elem):
|
|
||||||
"""
|
|
||||||
Get HTML string from document.
|
|
||||||
"""
|
|
||||||
return self.__parser.dump(elem)
|
|
||||||
|
|
||||||
def str(self, s):
|
def str(self, s):
|
||||||
if isinstance(s, unicode):
|
if isinstance(s, unicode):
|
||||||
s = s.encode('iso-8859-15', 'replace')
|
s = s.encode('iso-8859-15', 'replace')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue