{"record":{"id":"6f7f24bbf05dc859","repo":"run-llama/llama_index","slug":"bs4-is-required-to-read-html-files","errorCode":null,"errorMessage":"bs4 is required to read HTML files.","messagePattern":"bs4 is required to read HTML files\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/node_parser/file/html.py","lineNumber":76,"sourceCode":"        nodes: Sequence[BaseNode],\n        show_progress: bool = False,\n        **kwargs: Any,\n    ) -> List[BaseNode]:\n        all_nodes: List[BaseNode] = []\n        nodes_with_progress = get_tqdm_iterable(nodes, show_progress, \"Parsing nodes\")\n\n        for node in nodes_with_progress:\n            nodes = self.get_nodes_from_node(node)\n            all_nodes.extend(nodes)\n\n        return all_nodes\n\n    def get_nodes_from_node(self, node: BaseNode) -> List[TextNode]:\n        \"\"\"Get nodes from document.\"\"\"\n        try:\n            from bs4 import BeautifulSoup, Tag\n        except ImportError:\n            raise ImportError(\"bs4 is required to read HTML files.\")\n\n        text = node.get_content(metadata_mode=MetadataMode.NONE)\n        soup = BeautifulSoup(text, \"html.parser\")\n        html_nodes = []\n        last_tag = None\n        current_section = \"\"\n\n        tags = soup.find_all(self.tags)\n        for tag in tags:\n            tag_text = self._extract_text_from_tag(tag)\n            if isinstance(tag, Tag) and (tag.name == last_tag or last_tag is None):\n                last_tag = tag.name\n                current_section += f\"{tag_text.strip()}\\n\"\n            else:\n                # Skip empty sections (e.g. a container tag whose only children\n                # are themselves extracted tags) to avoid emitting blank nodes.\n                if current_section.strip():\n                    html_nodes.append(","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/node_parser/file/html.py#L58-L94","documentation":"Error \"bs4 is required to read HTML files.\" thrown in run-llama/llama_index.","triggerScenarios":"Thrown at llama-index-core/llama_index/core/node_parser/file/html.py:76 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Install beautifulsoup4: `pip install bs4`.","Use a different node parser that does not require bs4 for this input."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}