Skip to content

Commit 49fdd71

Browse files
authored
Merge pull request #36 from HIGHFIVE-SW/develop
[FIX] 문법 오류 수정
2 parents 1d60531 + 0f31dde commit 49fdd71

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

crawler/idealist_crawler.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from crawler.keyword_extractor import extract_keyword
55
from crawler.save_to_db import save_activities
66
from server.db import run_query
7+
from server.logger import logger
78

89
ENDPOINT = "https://nsv3auess7-dsn.algolia.net/1/indexes/*/queries"
910
HEADERS = {
@@ -83,7 +84,7 @@ def get_activities(page, timestamp, type):
8384
try:
8485
data = response.json()["results"][0]["hits"]
8586
except Exception as e:
86-
print(f"[!] JSON 파싱 에러: {e}")
87+
logger.error(f"[!] JSON 파싱 에러: {e}")
8788
return None
8889

8990
result = []
@@ -112,20 +113,20 @@ def get_activities(page, timestamp, type):
112113
"start_date": start_date
113114
}
114115
)
115-
print(f"[IDEALIST] 크롤링 완료 : {item.get("name", '')}")
116+
logger.info(f"[IDEALIST] 크롤링 완료 : {item.get('name', '')}")
116117
return result
117118
else:
118119
return None
119120

120121
def crawl():
121-
print("[IDEALIST] 크롤링 시작")
122+
logger.info("[IDEALIST] 크롤링 시작")
122123
crawled_activities = []
123124
last_timestamp = get_last_timestamp()
124125

125126
if last_timestamp > 0:
126-
print(f"[IDEALIST] DB의 마지막 활동 이후 데이터만 크롤링 시작 (TIMESTAMP: {last_timestamp})")
127+
logger.info(f"[IDEALIST] DB의 마지막 활동 이후 데이터만 크롤링 시작 (TIMESTAMP: {last_timestamp})")
127128
else:
128-
print(f"[IDEALIST] DB에 활동 없음, 모든 데이터 크롤링 시작")
129+
logger.info(f"[IDEALIST] DB에 활동 없음, 모든 데이터 크롤링 시작")
129130

130131
for type in ['volunteer', 'internship']:
131132
page = 0
@@ -137,10 +138,10 @@ def crawl():
137138
page += 1
138139

139140
if crawled_activities:
140-
print(f"[IDEALIST] 크롤링 완료 : {len(crawled_activities)}개의 활동을 크롤링했습니다.")
141+
logger.info(f"[IDEALIST] 크롤링 완료 : {len(crawled_activities)}개의 활동을 크롤링했습니다.")
141142
save_activities(crawled_activities)
142143
else:
143-
print("[IDEALIST] 크롤링 완료 : 새로운 활동이 없습니다.")
144+
logger.info("[IDEALIST] 크롤링 완료 : 새로운 활동이 없습니다.")
144145

145146
if __name__ == "__main__":
146147
crawl()

0 commit comments

Comments
 (0)