用BeautifulSoup 解析html和xml字符串
实例:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from bs4 import BeautifulSoup
import re
#待分析字符串
html_doc =
The Dormouse's story
The Dormouse's story
Once upon a
用BeautifulSoup 解析html和xml字符串
实例:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from bs4 import BeautifulSoup
import re
#待分析字符串
html_doc =
The Dormouse's story
The Dormouse's story
区别:
大白话说,就是find()可以应对于单个。然而find_all()却要一次查找好多!
代码:
import requests
from bs4 import BeautifulSoup
r = requests.get(https://python123.io/ws/demo.html)
demo = r.text
soup = BeautifulSoup(demo, html.parser)
print(soup)
print('\n')
for link in soup.find_