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
|
MESSAGE_PLATFORMS, MATTERMOST_URL, MATTERMOST_BOT_TOKEN, MATTERMOST_CHANNEL_ID
|
||||||
)
|
)
|
||||||
from lib.send_message import MessageSender
|
from lib.send_message import MessageSender
|
||||||
from lib.lib import (
|
from lib.common import (
|
||||||
create_mobile_driver,
|
create_mobile_driver,
|
||||||
save_cookies,
|
save_cookies,
|
||||||
load_cookies,
|
load_cookies,
|
||||||
@ -92,11 +92,13 @@ class NaverReviewCollector:
|
|||||||
for i in range(4, 7):
|
for i in range(4, 7):
|
||||||
try:
|
try:
|
||||||
el = li.find_element(By.XPATH, f"./div[{i}]/a")
|
el = li.find_element(By.XPATH, f"./div[{i}]/a")
|
||||||
if el and el.text.strip():
|
if el:
|
||||||
return clean_html_text(el.get_attribute("innerHTML"))
|
text = el.text.strip()
|
||||||
|
return clean_html_text(el.get_attribute("innerHTML")) if text else "내용 없음"
|
||||||
except Exception:
|
except Exception:
|
||||||
continue
|
continue
|
||||||
return None
|
return "내용 없음"
|
||||||
|
|
||||||
|
|
||||||
def extract_reviews(self):
|
def extract_reviews(self):
|
||||||
reviews = []
|
reviews = []
|
||||||
@ -132,8 +134,8 @@ class NaverReviewCollector:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
text = self.extract_review_text(li)
|
text = self.extract_review_text(li)
|
||||||
if not text:
|
#if not text:
|
||||||
continue
|
# continue
|
||||||
|
|
||||||
reviews.append({
|
reviews.append({
|
||||||
"작성자": author,
|
"작성자": author,
|
||||||
@ -248,6 +250,7 @@ class NaverReviewCollector:
|
|||||||
mattermost_token=MATTERMOST_BOT_TOKEN,
|
mattermost_token=MATTERMOST_BOT_TOKEN,
|
||||||
mattermost_channel_id=MATTERMOST_CHANNEL_ID,
|
mattermost_channel_id=MATTERMOST_CHANNEL_ID,
|
||||||
)
|
)
|
||||||
|
|
||||||
send_failure_message(sender, MESSAGE_PLATFORMS)
|
send_failure_message(sender, MESSAGE_PLATFORMS)
|
||||||
else:
|
else:
|
||||||
self.send_to_message()
|
self.send_to_message()
|
||||||
|
|||||||
@ -12,7 +12,7 @@ from conf.config import (
|
|||||||
MESSAGE_PLATFORMS, MATTERMOST_URL, MATTERMOST_BOT_TOKEN, MATTERMOST_CHANNEL_ID
|
MESSAGE_PLATFORMS, MATTERMOST_URL, MATTERMOST_BOT_TOKEN, MATTERMOST_CHANNEL_ID
|
||||||
)
|
)
|
||||||
from lib.send_message import MessageSender
|
from lib.send_message import MessageSender
|
||||||
from lib.lib import (
|
from lib.common import (
|
||||||
create_mobile_driver,
|
create_mobile_driver,
|
||||||
get_start_end_dates,
|
get_start_end_dates,
|
||||||
parse_korean_date,
|
parse_korean_date,
|
||||||
|
|||||||
4
requirements.txt
Normal file
4
requirements.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
selenium
|
||||||
|
requests
|
||||||
|
undetected_chromedriver
|
||||||
|
dotenv
|
||||||
Reference in New Issue
Block a user