From f43ecd744c0789f4b6ac0279435725bc8d424ae7 Mon Sep 17 00:00:00 2001 From: Arount Date: Thu, 20 Apr 2017 11:34:22 +0200 Subject: [PATCH] Add text 'No answers for this question ...' to avoid simple exist --- socli/socli.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/socli/socli.py b/socli/socli.py index beb279c..3ad55c4 100644 --- a/socli/socli.py +++ b/socli/socli.py @@ -239,6 +239,8 @@ def get_question_stats_and_answer(url): soup = BeautifulSoup(res_page.text, 'html.parser') question_title, question_desc, question_stats = get_stats(soup) answers = [s.get_text() for s in soup.find_all("div", class_="post-text")][1:] # first post is question, discard it. + if len(answers) == 0: + answers.append('No answers for this question ...') return question_title, question_desc, question_stats, answers