MCPcopy
hub / github.com/DedSecInside/TorBot / _append_node

Method _append_node

torbot/modules/linktree.py:46–61  ·  view source on GitHub ↗

Creates a node for a tree using the given ID which corresponds to a URL. If the parent_id is None, this will be considered a root node.

(self, id: str, parent_id: str | None)

Source from the content-addressed store, hash-verified

44 self._build_tree(url=self._url, depth=self._depth)
45
46 def _append_node(self, id: str, parent_id: str | None) -> None:
47 """
48 Creates a node for a tree using the given ID which corresponds to a URL.
49 If the parent_id is None, this will be considered a root node.
50 """
51 resp = self._client.get(id)
52 soup = BeautifulSoup(resp.text, 'html.parser')
53 title = soup.title.text.strip() if soup.title is not None else parse_hostname(id)
54 try:
55 [classification, accuracy] = classify(resp.text)
56 numbers = parse_phone_numbers(soup)
57 emails = parse_emails(soup)
58 data = LinkNode(title, id, resp.status_code, classification, accuracy, numbers, emails)
59 self.create_node(title, identifier=id, parent=parent_id, data=data)
60 except exceptions.DuplicatedNodeIdError:
61 logging.debug(f"found a duplicate URL {id}")
62
63 def _build_tree(self, url: str, depth: int) -> None:
64 """

Callers 2

loadMethod · 0.95
_build_treeMethod · 0.95

Calls 5

parse_hostnameFunction · 0.85
classifyFunction · 0.85
parse_phone_numbersFunction · 0.85
parse_emailsFunction · 0.85
LinkNodeClass · 0.85

Tested by

no test coverage detected