From 78e2b672b5f67f22145b6a12f571267250c33796 Mon Sep 17 00:00:00 2001 From: VikingKong Date: Wed, 14 Dec 2022 18:46:46 +0300 Subject: [PATCH] Fix some bugs in fetching Reddit comments. --- RedditCommentsParser.py | 6 +++++- Utils.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/RedditCommentsParser.py b/RedditCommentsParser.py index ec899d6..5d810b6 100644 --- a/RedditCommentsParser.py +++ b/RedditCommentsParser.py @@ -17,7 +17,11 @@ class RedditComments: return username + " " + date def getText(self, commentObj): - return commentObj.find("p").text + p = commentObj.find("p") + if p is not None: + return p.text + else: + return "" def getComments(self): for co in self.commentObjects: diff --git a/Utils.py b/Utils.py index db3b622..a8309c9 100644 --- a/Utils.py +++ b/Utils.py @@ -16,7 +16,7 @@ def checkReddit(link): def checkRedditComments(links): for link in links: - if re.search("^https://www.reddit.com/[a-z1-9/]+/comments", link) is not None: + if re.search("^https://www.reddit.com/[a-zA-Z1-9/]+/comments", link) is not None: return link return False