diff --git a/hacker_news/parser.py b/hacker_news/parser.py index 9145796..8c865f5 100644 --- a/hacker_news/parser.py +++ b/hacker_news/parser.py @@ -64,8 +64,9 @@ def parse_news_list(self): submit_time = self.human2datetime(submit_time) # In case of no comments yet comment_dom = subtext_dom.find('a', string=re.compile(r'\d+.+comment')) or Null + discuss_dom = subtext_dom.find('a', string=re.compile(r'discuss')) or Null comment_cnt = re.search(r'\d+', comment_dom.get_text() or '0').group() - comment_url = self.get_comment_url(comment_dom['href']) + comment_url = self.get_comment_url(comment_dom['href']) or self.get_comment_url(discuss_dom['href']) items.append(News( rank=rank, diff --git a/publish.py b/publish.py index c281189..84c9850 100644 --- a/publish.py +++ b/publish.py @@ -109,7 +109,7 @@ def gen_feed(news_list): ( ' [summary]' % f'{config.site}/#{news.slug()}'), ( - ' [comments]' % news.comment_url if news.comment_url and news.comment_url else '')), + ' [comments]' % news.comment_url if news.comment_url else '')), author={ 'name': news.author, 'uri': news.author_link diff --git a/test/test_html_parser.py b/test/test_html_parser.py index cdc337c..4948a57 100644 --- a/test/test_html_parser.py +++ b/test/test_html_parser.py @@ -237,12 +237,12 @@ def test_arxiv_content(self): def test_link_intensive_wikipedia(self): parser = parser_factory('https://en.wikipedia.org/wiki/Google_Sidewiki') content = parser.get_content() - self.assertTrue(content.startswith('Google Sidewiki was a web annotation tool from Google')) + self.assertTrue(content.startswith('Google Sidewiki was a web annotation tool from Google'), msg=content[:100]) def test_dynamic_js_page(self): parser = parser_factory('https://www.science.org/content/article/u-s-wants-change-how-researchers-get-access-huge-trove-health-data-many-don-t-idea') content = parser.get_content() - self.assertTrue(content.startswith('Health researchers')) + self.assertTrue(content.startswith('Health researchers'), msg=content[:100]) def test_longer_meta_description(self): html_doc = """