diff options
author | icoz <icoz.vt@gmail.com> | 2017-02-12 16:58:11 +0300 |
---|---|---|
committer | icoz <icoz.vt@gmail.com> | 2017-02-12 16:58:11 +0300 |
commit | 2f348b624d40230794d5eaefc14cc85e93fbf68b (patch) | |
tree | 7bb43faf7d7a12868f5160ed2a56a1d383917cd0 | |
parent | c66b4859fa5244a166cefd96761fc8360a5fe3b8 (diff) |
Исправлен баг после merge pull-request
-rw-r--r-- | habr/topic.py | 12 | ||||
-rw-r--r-- | requirements.txt | 2 |
2 files changed, 9 insertions, 5 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'] = '' diff --git a/requirements.txt b/requirements.txt index 83aed1c..5248704 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,5 +11,5 @@ Pyphen==0.9.4 requests==2.12.3 six==1.10.0 tinycss==0.4 -WeasyPrint>=0.34 +WeasyPrint>=0.33 webencodings==0.5 |