import urllib.request
import requests
from bs4 import BeautifulSoup
from urllib import request
html=urllib.request.urlopen("https://www.audibrand.cn/")
data=html.read()
datas=BeautifulSoup(data,"html.parser")//将获得的页面以html树型的方式呈现,而不是挤在一行,并且如果没有这条语句,使用find()函数会报错
# print(datas)
a=datas.find("video",attrs={"class":"video-player mobile-video embeded-video"})
# print(a)
b=a.find("source")
c=b.get("src")
# print(c)
urls="https://www.audibrand.cn/"+c
urllib.request.urlretrieve(urls,"shiping/1.mp4")//视频的爬取与下载与图片类似,但是要把后缀换成.mp4
# print(b)
# print(b)
代码如上,与图片爬取类似,但是需要修改后缀名