Python爬虫利器之Beautiful Soup的用法,以及实例!

可以利用 pip 来安装:

pip install beautifulsoup4

源代码:

import requests
r = requests.get("https://python123.io/ws/demo.html")
r.text
demo = r.text
from bs4 import BeautifulSoup
soup = BeautifulSoup(demo , "html.parser")
print(soup.prettify())

原网页,右键查看源代码:
在这里插入图片描述
利用爬虫执行之后:
在这里插入图片描述
可以看到树形的代码结构!

技术参考文档:https://cuiqingcai.com/1319.html

猜你喜欢

转载自blog.csdn.net/weixin_42859280/article/details/84195955