MCPcopy Create free account
hub / github.com/THUDM/AutoWebGLM / ctx2tree

Method ctx2tree

webarena/browser_env/html_tools/html_parser.py:126–133  ·  view source on GitHub ↗
(ctx: str)

Source from the content-addressed store, hash-verified

124
125 @staticmethod
126 def ctx2tree(ctx: str) -> html.HtmlElement:
127 # remove useless tags, eg. style and script
128 ctx = re.sub('<!--[\W\w]*?-->', '', ctx)
129 ctx = re.sub('<style[\W\w]*?>[\W\w]*?</style>', '', ctx)
130 ctx = re.sub('<script[\W\w]*?>[\W\w]*?</script>', '', ctx)
131 ctx = '' if ctx is None else re.sub(r'\s+', ' ', ctx).strip()
132 dom_tree = html.fromstring(ctx)
133 return dom_tree
134
135 @staticmethod
136 def get_root(tree: html.HtmlElement) -> html.HtmlElement:

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected