bs4爬虫

#html标签的筛选

#拿到页面源代码
#使用bs4进行解析
import time
import requests
import csv
from bs4 import BeautifulSoup

header= {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36"
    }
url="https://www.umeitu.com/bizhitupian/weimeibizhi/"
requ=requests.get(url)
print(requ.text)
time.sleep(0.5)

bs4是对hrml上相应标签内容进行查询,根据标签属性查找对应标签的内容

page=beautifulsoup(resp.text,"html.parser")

#find(标签,属性=值)

#find_all(标签,属性=值)

page.find("table",class_="属性值")

posted @ 2022-04-26 10:01  凋零_(  阅读(27)  评论(0编辑  收藏  举报