1.用管理员身份运行cmd
2.pip install beautifulsoup4 (不是beautifulsoup)
bs4主要方法:

exp:以获取百度标题为例
import requests #导入requests库
from bs4 import BeautifulSoup #导入BeautifulSoup方法 主要大小写
r = requests.get('http://www.baidu.com') #r为
r.raise_for_status()
r.encoding = r.apparent_encoding
html = BeautifulSoup(r.text)
print(html.title) #输出获取html代码中title标签内容
本文介绍如何利用Python的BeautifulSoup库从指定网站抓取标题。通过实例演示了使用requests库获取网页内容,并利用BeautifulSoup解析HTML文档,最终提取出网页的标题。
3131

被折叠的 条评论
为什么被折叠?



