MCPcopy Create free account
hub / github.com/NanmiCoder/MediaCrawler / extract_text_from_html

Function extract_text_from_html

tools/crawler_util.py:215–224  ·  view source on GitHub ↗

Extract text from HTML, removing all tags.

(html: str)

Source from the content-addressed store, hash-verified

213
214
215def extract_text_from_html(html: str) -> str:
216 """Extract text from HTML, removing all tags."""
217 if not html:
218 return ""
219
220 # Remove script and style elements
221 clean_html = re.sub(r'<(script|style)[^>]*>.*?</\1>', '', html, flags=re.DOTALL)
222 # Remove all other tags
223 clean_text = re.sub(r'<[^>]+>', '', clean_html).strip()
224 return clean_text
225
226def extract_url_params_to_dict(url: str) -> Dict:
227 """Extract URL parameters to dict"""

Callers 4

_extract_commentMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected