小白学爬虫笔记4---beautifulsoup库

Beautiful Soup(美味汤)库

可以进行任何格式的爬取并进行树形解析

安装

pip3 install beautifulsoup4

演示地址

python123.io/ws/demo.html

语法

from bs4 import BeautifulSoup
soup = BeautifulSoup('<p>data</p>','html.parser')

例子

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

猜你喜欢

转载自blog.csdn.net/paleyellow/article/details/81063103
今日推荐