BeautifulSoup4总结
BeautifulSoup4 介绍与安装
Beautiful Soup
从HTML或XML文件中提取数据的Python库(bs4)
Beautiful Soup 4.4.0 文档
安装 Beautiful Soup(且要安装lxml作为解析器)pip install beautifulsoup4
pip install lxml
源码:Beautiful Soup
BeautifulSoup4 使用
导入 Beautiful Soup 库
from bs4 import BeautifulSoup
import requests
使用 requests 获取网页内容
url = 'https://baidu.com/'
response = requests.get(url)
创建 BeautifulSoup 对象
soup = BeautifulSoup(response.text, 'lxml')
输出结果
print(soup)
1 | from bs4 import BeautifulSoup |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 微光zc的网络小窝!
评论