Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/icoz/habraparse.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'habr/topic.py')
-rw-r--r--habr/topic.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/habr/topic.py b/habr/topic.py
index fdf56f9..d83d8e4 100644
--- a/habr/topic.py
+++ b/habr/topic.py
@@ -50,12 +50,16 @@ class TMTopic(object):
if len(post_title) == 0:
raise PostDeleted
self.post['title'] = post_title
- tmp = doc.xpath("//div[@class='author-info__username']//a[@class='author-info__nickname']") or \
- doc.xpath("//div[@class='author-info__username']//a[@class='author-info__name']") or \
- doc.xpath("//div[@class='author-info__username']//span[@class='author-info__name']")
+ tmp = \
+ doc.xpath("//div[@class='author-info__username']//a[@class='author-info__nickname']") or \
+ doc.xpath("//div[@class='author-info__username']//a[@class='author-info__name']") or \
+ doc.xpath("//div[@class='author-info__username']//span[@class='author-info__name']")
if len(tmp):
- self.post['author_url'] = ('https://' + self.domain + tmp[0].attrib['href'] )
self.post['author'] = tmp[0].text
+ if tmp[0].attrib.get('href'):
+ self.post['author_url'] = ('https://' + self.domain + tmp[0].attrib['href'] )
+ else:
+ self.post['author_url'] = "https://{}/users/{}".format(self.domain, self.post['author'])
else:
self.post['author_url']= ''
self.post['author'] = ''