import subprocess
def download_bilibili_video(video_url):
try:
# 使用you-get下载视频,-o指定输出目录(这里是当前目录)
subprocess.run([‘you-get’, ‘-o’, ‘.’, video_url], check=True)
print(“视频下载成功!”)
except subprocess.CalledProcessError as e:
print(“下载过程中出现错误:”, e)
if name == “main”:
base_url = “https://www.bilibili.com/video/BV1xp4y1t7Dv?track_id=pbaes.wwjDdgD3n_YSxV4yEXuYtTAzQ7AeLbukxo5bTgStRvnNNpi6dBG4Da1QXBoDtFpjuDmJFDw3CoIBZjwkWBXW_6spzrVSDjkgaWNnt9IfabccE0ua1k8ttKmnAoGUKGDIpiGZcJdVT5D_lqO9KKyKy3X8RdKlApobNv5u9ZW0HQ3zBx7NfokVkXAGitl4PwNv&trackid=FROMTRACKID&caid=CAID&resource_id=RESOURCEID&source_id=5647&from_spmid=FROMSPMID&request_id=1733308591311q172a27a118a19q9900&creative_id=187888088&linked_creative_id=187888088&vd_source=3953750b452f488a0e98a8da254e1c9f&spm_id_from=333.788.videopod.episodes&p=”
for page in range(1, 11): # 假设要下载前10页,可根据实际需求修改范围
video_url = base_url + str(page)
download_bilibili_video(video_url)