MCPcopy
hub / github.com/LawRefBook/Laws / get_html

Method get_html

scripts/request.py:205–216  ·  view source on GitHub ↗
(self, url)

Source from the content-addressed store, hash-verified

203 return ret
204
205 def get_html(self, url) -> str:
206 cache_key = os.path.basename(url)
207 if cache := self.cache.get(cache_key, CacheType.HTMLDocument, "html"):
208 return cache
209 logger.debug(f"getting law html file {url}")
210 response = requests.get('https://wb.flk.npc.gov.cn' + url,
211 headers=REQUEST_HEADER)
212 sleep(1)
213 response.encoding = "utf8"
214 ret = response.text
215 self.cache.set(cache_key, CacheType.HTMLDocument, ret, "html")
216 return ret
217
218 def get_word(self, url) -> Document:
219 filename = os.path.basename(url)

Callers 1

parseMethod · 0.80

Calls 2

getMethod · 0.80
setMethod · 0.80

Tested by

no test coverage detected