diff --git a/scripts/law_monitor.py b/scripts/law_monitor.py index d61e945..39e5d74 100644 --- a/scripts/law_monitor.py +++ b/scripts/law_monitor.py @@ -241,7 +241,6 @@ def fetch_us_osha(last_check: dict) -> int: from_date = (datetime.now() - timedelta(days=7)).strftime("%Y-%m-%d") resp = requests.get("https://www.federalregister.gov/api/v1/documents.json", params={ "conditions[agencies][]": "occupational-safety-and-health-administration", - "conditions[type][]": ["RULE", "PRORULE"], "conditions[publication_date][gte]": from_date, "per_page": 10, "order": "newest", @@ -296,15 +295,16 @@ def fetch_jp_mhlw(last_check: dict) -> int: resp.raise_for_status() root = ET.fromstring(resp.content) - safety_keywords = ["労働安全", "安全衛生", "労災", "化学物質", "石綿", "安全管理"] - ns = {"rss": "http://purl.org/rss/1.0", "dc": "http://purl.org/dc/elements/1.1/"} + safety_keywords = ["労働安全", "安全衛生", "労災", "化学物質", "石綿", "安全管理", "労働", "安全", "衛生"] + rss_ns = "http://purl.org/rss/1.0/" count = 0 - # RDF 1.0 형식: 또는 {ns}item - items = root.findall("rss:item", ns) or root.iter("item") + # RDF 1.0 형식: {http://purl.org/rss/1.0/}item + items = root.findall(f"{{{rss_ns}}}item") + logger.info(f"JP RSS 항목: {len(items)}건") for item in items: - title = item.findtext("rss:title", "", ns) or item.findtext("title", "") - link = item.findtext("rss:link", "", ns) or item.findtext("link", "") + title = item.findtext(f"{{{rss_ns}}}title", "") + link = item.findtext(f"{{{rss_ns}}}link", "") pub_date = item.findtext("pubDate", "") # 안전위생 키워드 필터