import xlrd2 import os import time import requests def download_video(): data = xlrd2.open_workbook(r"C:\Users\jonie\Desktop\word_video.xlsx") table = data.sheets()[0] tables = [] for row in range(table.nrows): array = {'number': table.cell_value(row, 0), 'video_url': table.cell_value(row, 1)} tables.append(array) for i in tables[1:]: path = r"C:\Users\jonie\Desktop\word_video" os.chdir(path) video_list = i['video_url'] time.sleep(1) # 设置间隔时间,防止把网页爬崩 response = requests.get(video_list) with open(path + '\\' + video_list.split("audio=")[1].split("&")[0] + video_list.split("type=")[1] + '.mp3', 'wb') as f: f.write(response.content) if __name__ == '__main__': download_video()
python批量爬取网站音频
最新推荐文章于 2024-07-15 10:36:04 发布