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:
authorkvakanet <kvakanet@users.noreply.github.com>2017-02-12 19:48:09 +0300
committerGitHub <noreply@github.com>2017-02-12 19:48:09 +0300
commit51f87c770dead1c87f592b6a6936013c1a29348d (patch)
tree49fbd385c9a3ba4ba084d4634c7717fd76165bbb
parent13304cfa97702ac688346bca7274c13cae94478a (diff)
Geektimes автор исправление и дополнение
Для вставки ссылки на автора из статей geektimes исправлено если href не находится.
-rw-r--r--habr/topic.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/habr/topic.py b/habr/topic.py
index d83d8e4..97ff40e 100644
--- a/habr/topic.py
+++ b/habr/topic.py
@@ -51,15 +51,13 @@ class TMTopic(object):
raise PostDeleted
self.post['title'] = post_title
tmp = \
+ doc.xpath("//a[@class='post-type__value post-type__value_author']") or \
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'] = 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'])
+ self.post['author_url'] = ('https://' + self.domain + tmp[0].attrib['href'] ) if 'href' in tmp[0].attrib else ''
else:
self.post['author_url']= ''
self.post['author'] = ''