当前位置: 移动技术网 > IT编程>脚本编程>Python > Python获取网络数据之安装bs4库及实例应用讲解

Python获取网络数据之安装bs4库及实例应用讲解

2018年09月24日  | 移动技术网IT编程  | 我要评论

青岛小琴系列快播,惊门 笔趣阁,四平青年风云再起

1.用管理员身份运行cmd

2.pip install beautifulsoup4 (不是beautifulsoup)

bs4主要方法:

\

exp:以获取百度标题为例

import requests #导入requests库

from bs4 import beautifulsoup #导入beautifulsoup方法 主要大小写

r = requests.get('https://www.baidu.com') #r为

r.raise_for_status()

r.encoding = r.apparent_encoding

html = beautifulsoup(r.text)

print(html.title) #输出获取html代码中title标签内容

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网