From 72a12ac29f34455443f6848b41dc3dec869a47e3 Mon Sep 17 00:00:00 2001 From: KWON Date: Mon, 14 Jul 2025 13:14:38 +0900 Subject: [PATCH] =?UTF-8?q?requirements.txt=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20lib.py=20>=20common.py=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=EA=B3=BC=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/biz_crawler.py | 17 ++++++++++------- lib/{lib.py => common.py} | 0 lib/naver_review_crawler.py | 2 +- requirements.txt | 4 ++++ 4 files changed, 15 insertions(+), 8 deletions(-) rename lib/{lib.py => common.py} (100%) create mode 100644 requirements.txt diff --git a/lib/biz_crawler.py b/lib/biz_crawler.py index 67b31d4..4667314 100644 --- a/lib/biz_crawler.py +++ b/lib/biz_crawler.py @@ -14,7 +14,7 @@ from conf.config import ( MESSAGE_PLATFORMS, MATTERMOST_URL, MATTERMOST_BOT_TOKEN, MATTERMOST_CHANNEL_ID ) from lib.send_message import MessageSender -from lib.lib import ( +from lib.common import ( create_mobile_driver, save_cookies, load_cookies, @@ -92,11 +92,13 @@ class NaverReviewCollector: for i in range(4, 7): try: el = li.find_element(By.XPATH, f"./div[{i}]/a") - if el and el.text.strip(): - return clean_html_text(el.get_attribute("innerHTML")) + if el: + text = el.text.strip() + return clean_html_text(el.get_attribute("innerHTML")) if text else "내용 없음" except Exception: continue - return None + return "내용 없음" + def extract_reviews(self): reviews = [] @@ -132,8 +134,8 @@ class NaverReviewCollector: continue text = self.extract_review_text(li) - if not text: - continue + #if not text: + # continue reviews.append({ "작성자": author, @@ -241,13 +243,14 @@ class NaverReviewCollector: self.reviews_by_place[place_name] = [] self.driver.quit() - + if not self.reviews_by_place: sender = MessageSender( mattermost_url=MATTERMOST_URL, mattermost_token=MATTERMOST_BOT_TOKEN, mattermost_channel_id=MATTERMOST_CHANNEL_ID, ) + send_failure_message(sender, MESSAGE_PLATFORMS) else: self.send_to_message() diff --git a/lib/lib.py b/lib/common.py similarity index 100% rename from lib/lib.py rename to lib/common.py diff --git a/lib/naver_review_crawler.py b/lib/naver_review_crawler.py index a11f03b..5183bc4 100644 --- a/lib/naver_review_crawler.py +++ b/lib/naver_review_crawler.py @@ -12,7 +12,7 @@ from conf.config import ( MESSAGE_PLATFORMS, MATTERMOST_URL, MATTERMOST_BOT_TOKEN, MATTERMOST_CHANNEL_ID ) from lib.send_message import MessageSender -from lib.lib import ( +from lib.common import ( create_mobile_driver, get_start_end_dates, parse_korean_date, diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..61fbeac --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +selenium +requests +undetected_chromedriver +dotenv