Skip to content

Commit 03f25db

Browse files
committed
Append bs4__BeautifulSoup__examples/about_builders.py
1 parent 797cc30 commit 03f25db

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
__author__ = 'ipetrash'
5+
6+
7+
# pip install lxml
8+
# pip install html5lib
9+
# pip install bs4
10+
11+
from bs4 import BeautifulSoup
12+
13+
14+
text = "<xml/>"
15+
16+
root = BeautifulSoup(text, 'html.parser')
17+
print(root.builder) # bs4.builder._htmlparser.HTMLParserTreeBuilder
18+
19+
root = BeautifulSoup(text, 'html5lib')
20+
print(root.builder) # bs4.builder._html5lib.HTML5TreeBuilder
21+
22+
root = BeautifulSoup(text, 'xml')
23+
print(root.builder) # bs4.builder._lxml.LXMLTreeBuilderForXML
24+
25+
root = BeautifulSoup(text, 'lxml-xml')
26+
print(root.builder) # bs4.builder._lxml.LXMLTreeBuilderForXML
27+
28+
root = BeautifulSoup(text, 'lxml')
29+
print(root.builder) # bs4.builder._lxml.LXMLTreeBuilder
30+
31+
root = BeautifulSoup(text, 'lxml-html')
32+
print(root.builder) # bs4.builder._lxml.LXMLTreeBuilder

0 commit comments

Comments
 (0)