5. 파이썬
BeautifulSoup 입문예제 30th
패스트코드블로그
2020. 9. 16. 22:33
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
from bs4 import BeautifulSoup # conda install -c anaconda beautifulsoup4
import re
doc = ['<html><head><title>Page title</title></head>',
'<body><p id="firstpara" align="center">This is paragraph <b>one</b>.',
'<p id="secondpara" align="blah">This is paragraph <b>two</b>.',
'</html>']
soup = BeautifulSoup(''.join(doc))
print(soup.prettify())
"""
<html>
<head>
<title>
Page title
</title>
</head>
<body>
<p align="center" id="firstpara">
This is paragraph
<b>
one
</b>
.
<p align="blah" id="secondpara">
This is paragraph
<b>
two
</b>
.
</p>
</p>
</body>
</html>
"""
|
cs |
************
1 2 3 4 5 6 7 8 9 10 11 | from bs4 import BeautifulSoup # conda install -c anaconda beautifulsoup4 import re doc = ['<html><head><title>Page title</title></head>', '<body><p id="firstpara" align="center">This is paragraph <b>one</b>.', '<p id="secondpara" align="blah">This is paragraph <b>two</b>.', '</html>'] soup = BeautifulSoup(''.join(doc)) print(soup.prettify()) | cs |