import requests
from lxml import etree
headers = {
'authority': 'ibaotu.com',
'pragma': 'no-cache',
'cache-control': 'no-cache',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36',
'accept': '*/*',
'origin': 'https://plus.ibaotu.com',
'sec-fetch-site': 'same-site',
'sec-fetch-mode': 'cors',
'sec-fetch-dest': 'empty',
'referer': 'https://plus.ibaotu.com/search?category=%E8%A7%86%E9%A2%91&keyword=',
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
'cookie': 'md_session_id=20230719003256124; user_refers=a%3A2%3A%7Bi%3A0%3Bs%3A3%3A%22bwd%22%3Bi%3A1%3Bs%3A13%3A%22www.baidu.com%22%3B%7D; new_edition_type_v4=1; __is_small_screen=1; Hm_lvt_4df399c02bb6b34a5681f739d57787ee=1689776260; Hm_lpvt_4df399c02bb6b34a5681f739d57787ee=1689776260; md_session_expire=1800; FIRSTVISITED=1689776264.704; from_type=; referer=http%3A%2F%2Fibaotu.com%2F%3Fm%3DAjaxSearch%26a%3Ddef; _clck=epszo2|2|fdf|0|1295; _clsk=1kodr2i|1689777324327|5|1|y.clarity.ms/collect',
}
params = {
'm': 'PlusApi',
'a': 'search',
'keyword': '',
'tabname': '视频',
'c1': '',
'c2': '',
'c3': '',
'c4': '',
'format_type': '',
'width': '',
'height': '',
'copyright': '',
'resolution': '',
'duration': '',
'page': '3',
'size': '80',
'sort': '',
'format': '',
'color': '',
}
response = requests.get(url=f'https://ibaotu.com/shipin/7-0-0-0-0-1.html', headers=headers) # 发送请求
html_text = response.content.decode('utf-8') # 编译
html = etree.HTML(html_text) # 自动修正html文档
src_list = html.xpath('//div[@class="video-play"]/video/@src') # 视频网址
title_list = html.xpath('//span[@class="video-title"]/text()') # 视频名称
for src, title in zip(src_list, title_list):
res = requests.get('https:' + src, headers=headers)
filename = title + '.mp4'
print('正在下载视频:' + filename)
with open('video/' + filename, 'wb') as f:
f.write(res.content)
请问怎么实现翻页获取多页视频,