MCPcopy
hub / github.com/1Panel-dev/MaxKB / fork

Method fork

apps/common/utils/fork.py:185–206  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

183 return charset_list
184
185 def fork(self):
186 try:
187
188 headers = {
189 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36'
190 }
191
192 maxkb_logger.info(f'fork:{self.base_fork_url}')
193 response = requests.get(self.base_fork_url, verify=False, headers=headers)
194 if response.status_code != 200:
195 maxkb_logger.error(f"url: {self.base_fork_url} code:{response.status_code}")
196 return Fork.Response.error(f"url: {self.base_fork_url} code:{response.status_code}")
197 bf = self.get_beautiful_soup(response)
198 except Exception as e:
199 maxkb_logger.error(f'{str(e)}:{traceback.format_exc()}')
200 return Fork.Response.error(str(e))
201 bf = self.reset_beautiful_soup(bf)
202 link_list = self.get_child_link_list(bf)
203 content = self.get_content_html(bf)
204
205 r = markdownify(content, heading_style='ATX')
206 return Fork.Response.success(r, link_list)
207
208
209def handler(base_url, response: Fork.Response):

Callers 7

is_validMethod · 0.45
syncMethod · 0.45
sync_web_knowledgeFunction · 0.45
sync_web_documentFunction · 0.45
executeMethod · 0.45
fork_childMethod · 0.45

Calls 7

get_beautiful_soupMethod · 0.95
reset_beautiful_soupMethod · 0.95
get_child_link_listMethod · 0.95
get_content_htmlMethod · 0.95
getMethod · 0.45
errorMethod · 0.45
successMethod · 0.45

Tested by

no test coverage detected