requirements.txt 추가 및 lib.py > common.py 수정과 리팩토링
This commit is contained in:
@ -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()
|
||||
|
||||
Reference in New Issue
Block a user