diff --git a/WebBasedCrawler/kakao/kakaocrawl.py b/WebBasedCrawler/kakao/kakaocrawl.py index 3b892b8..05c4497 100644 --- a/WebBasedCrawler/kakao/kakaocrawl.py +++ b/WebBasedCrawler/kakao/kakaocrawl.py @@ -61,6 +61,9 @@ def get_date(element): if m.group(4) == "오후" and int(m.group(5)) < 12: temp_date += datetime.timedelta(hours=12) + if m.group(4) == "오전" and int(m.group(5)) == 12: + temp_date -= datetime.timedelta(hours=12) + # convert datetime.datetime to str return str(temp_date) # return invalid date instead of exception @@ -186,6 +189,10 @@ class BodyCrawler(object): if m.group(4) == "오후" and int(m.group(5)) < 12: temp_date += datetime.timedelta(hours=12) + # sub 12 hour when the article is written at 12 a.m + if m.group(4) == "오전" and int(m.group(5)) == 12: + temp_date -= datetime.timedelta(hours=12) + # convert datetime.datetime to str return str(temp_date) else: @@ -224,6 +231,10 @@ class BodyCrawler(object): if m.group(4) == "오후" and int(m.group(5)) < 12: temp_date += datetime.timedelta(hours=12) + # sub 12 hour when the article is written at 12 a.m + if m.group(4) == "오전" and int(m.group(5)) == 12: + temp_date -= datetime.timedelta(hours=12) + # convert datetime.datetime to str return str(temp_date) # return invalid date instead of exception