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

Method ctx2tree

miniwob++/html_tools/html_parser.py:121–128  ·  view source on GitHub ↗
(ctx: str)

Source from the content-addressed store, hash-verified

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

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected