MCPcopy Create free account
hub / github.com/RASAAS/docmcp-knowledge / _parse_whatsnew

Method _parse_whatsnew

scripts/fetch_updates.py:2003–2054  ·  view source on GitHub ↗

Parse PMDA What's New page -- list items with date, category, and title.

(html: str)

Source from the content-addressed store, hash-verified

2001
2002 @staticmethod
2003 def _parse_whatsnew(html: str) -> list[dict]:
2004 """Parse PMDA What's New page -- list items with date, category, and title."""
2005 _TAG_RE = re.compile(
2006 r"^(?:(?:January|February|March|April|May|June|July|August|"
2007 r"September|October|November|December)\s+\d{1,2},?\s*\d{4})"
2008 r"\s*"
2009 r"(?:Review|Safety|Other|Events|Int|JP|Devices?|Drug|Regen\.?|IVD|CDx)*"
2010 r"\s*(?:New)?\s*",
2011 re.IGNORECASE,
2012 )
2013 results = []
2014 try:
2015 from bs4 import BeautifulSoup
2016 soup = BeautifulSoup(html, "html.parser")
2017 for li in soup.find_all("li"):
2018 text = li.get_text(" ", strip=True)
2019 dm = re.search(
2020 r"((?:January|February|March|April|May|June|July|August|"
2021 r"September|October|November|December)\s+\d{1,2},?\s*\d{4})",
2022 text,
2023 )
2024 if not dm:
2025 continue
2026 date_str = dm.group(1)
2027 a_tag = li.find("a")
2028 if a_tag and a_tag.get("href"):
2029 title = a_tag.get_text(strip=True)
2030 href = a_tag["href"]
2031 if not href.startswith("http"):
2032 href = "https://www.pmda.go.jp" + href
2033 else:
2034 remainder = text[dm.end():].strip()
2035 remainder = re.sub(
2036 r"^(?:Review|Safety|Other|Events|Int|JP|Devices?|Drug|Regen\.?|IVD|CDx)\s*",
2037 "", remainder,
2038 ).strip()
2039 remainder = re.sub(r"^New\s*", "", remainder).strip()
2040 title = remainder
2041 href = ""
2042 if not title or len(title) < 10:
2043 continue
2044 title = re.sub(r"\s*\[\d+\s*KB\]", "", title).strip()
2045 title = _TAG_RE.sub("", title).strip()
2046 results.append({
2047 "title": title,
2048 "link": href,
2049 "pub_date": date_str,
2050 "description": "",
2051 })
2052 except ImportError:
2053 pass
2054 return results[:50]
2055
2056
2057class PMDAChecker:

Callers 1

checkMethod · 0.95

Calls 2

getMethod · 0.80
searchMethod · 0.45

Tested by

no test coverage detected