Skip to content

Commit

Permalink
fix index error
Browse files Browse the repository at this point in the history
  • Loading branch information
GoGiants1 committed Feb 26, 2024
1 parent 88d4626 commit 33934a3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crawlers/base_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ async def run(self, url=None, **kwargs):
soup = BeautifulSoup(html, "html.parser")
self.crawl(soup, **kwargs)
except Exception as e:
print(e)
print(f"Error in Run: {str(e)}")

def normalize(self, meal, **kwargs):
for normalizer_cls in self.normalizer_classes:
Expand Down
17 changes: 13 additions & 4 deletions crawlers/snuco_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,18 @@ class SnucoRestaurantCrawler(RestaurantCrawler):

def __init__(self):
super().__init__()
self.not_meal += ["셋트메뉴", "단품메뉴", "사이드메뉴", "결제", "혼잡시간", r"말렌카케이크", "1조각홀케이크", "식사", "메뉴", "사이드"]
self.not_meal += [
"셋트메뉴",
"단품메뉴",
"사이드메뉴",
"결제",
"혼잡시간",
r"말렌카케이크",
"1조각홀케이크",
"식사",
"메뉴",
"사이드",
]

def is_next_line_keyword(self, meal):
if not meal:
Expand Down Expand Up @@ -145,13 +156,11 @@ def found_meal(self, meal):

def crawl(self, soup, **kwargs):
date = kwargs.get("date", datetime.datetime.now(timezone("Asia/Seoul")).date())
table = soup.select_one("div.view-content > table")
table = soup.find("table", {"class": "menu-table"})
if not table:
return

ths = table.select("thead > tr > th")
trs = table.tbody.find_all("tr", recursive=False)

types = []
for th in ths[1:]:
types.append(th.text)
Expand Down
1 change: 0 additions & 1 deletion handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def menus_transaction(crawled_meals, cursor):
"""
cursor.execute(get_menus_query)
db_menus = cursor.fetchall()

new_menus, deleted_menus, edited_menus = compare_menus(db_menus, crawled_meals, restaurants)

if deleted_menus:
Expand Down

0 comments on commit 33934a3

Please sign in to comment.