new attribute 'username' on comments
This commit is contained in:
parent
64959ad28d
commit
cea58c23e4
1 changed files with 6 additions and 1 deletions
|
|
@ -31,6 +31,7 @@ class Comment(object):
|
||||||
self.reply_id = reply_id
|
self.reply_id = reply_id
|
||||||
self.title = u''
|
self.title = u''
|
||||||
self.author = u''
|
self.author = u''
|
||||||
|
self.username = None
|
||||||
self.date = None
|
self.date = None
|
||||||
self.body = u''
|
self.body = u''
|
||||||
self.score = 0
|
self.score = 0
|
||||||
|
|
@ -41,9 +42,13 @@ class Comment(object):
|
||||||
self.url = '%s#%s' % (article.url, div.attrib['id'])
|
self.url = '%s#%s' % (article.url, div.attrib['id'])
|
||||||
self.title = unicode(select(div.find('h2'), 'a.title', 1).text)
|
self.title = unicode(select(div.find('h2'), 'a.title', 1).text)
|
||||||
try:
|
try:
|
||||||
self.author = unicode(select(div.find('p'), 'a[rel=author]', 1).text)
|
a = select(div.find('p'), 'a[rel=author]', 1)
|
||||||
except SelectElementException:
|
except SelectElementException:
|
||||||
self.author = 'Anonyme'
|
self.author = 'Anonyme'
|
||||||
|
self.username = None
|
||||||
|
else:
|
||||||
|
self.author = unicode(a.text)
|
||||||
|
self.username = unicode(a.attrib['href'].lstrip('/users/'))
|
||||||
self.date = datetime.strptime(select(div.find('p'), 'time', 1).attrib['datetime'].split('+')[0],
|
self.date = datetime.strptime(select(div.find('p'), 'time', 1).attrib['datetime'].split('+')[0],
|
||||||
'%Y-%m-%dT%H:%M:%S')
|
'%Y-%m-%dT%H:%M:%S')
|
||||||
self.date = local2utc(self.date)
|
self.date = local2utc(self.date)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue