抖音火山版批量无水印下载(python)脚本
程序员文章站
2022-04-11 17:02:07
...
抖音火山版批量无水印下载(python)脚本
import requests
import os
# 忽略警告代码
requests.packages.urllib3.disable_warnings()
#下载
# 获取字符串中指定字符
def getMidString(html, start_str, end):
start = html.find(start_str)
if start >= 0:
start += len(start_str)
end = html.find(end, start)
if end >= 0:
return html[start:end]
def getRealUrl(index,url):
headers = {
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1',
}
# 重定向地址
response = requests.get(url, headers=headers, allow_redirects=False,verify=False)
item_id = getMidString(response.headers["Location"], 'item_id=', '&tag=')
api_url = 'https://share.huoshan.com/api/item/info?item_id=' + item_id
api_response = requests.get(api_url,headers=headers,verify=False).json()
waterMarkVideo = api_response['data']['item_info']['url']
# 替换reflow为resource mark=2为mark=0
noWaterMarkVideo = waterMarkVideo.replace('reflow','source').replace('mark=2','mark=0')
print('you-get -o d:/1 -O D:/1/{}.mp4 {} '.format(url,noWaterMarkVideo))
os.system('you-get -o d:/1 -O D:/1/{} {} '.format(index,noWaterMarkVideo))
print(noWaterMarkVideo)
print('%s 下载成功!' % url)
# 读取excel数据
import xlrd
import xlwt
# 获取10行数据 并且储存在列表ls里
ls=[]
for i in range(10):
# 修改链接地址路径
shuju = xlrd.open_workbook("D:/1/123.xlsx")
# 获取sheet名字
allsheetnamee= shuju.sheet_names()[0]
# 获取sheet内容
sheet1 = shuju.sheet_by_index(0)
# print(sheet1.row_values(i))
# print(sheet1.cell(i,0).value) 获取第一列的内容
ls.append(sheet1.cell(i,0).value)
for index,i in enumerate(ls):
i=i[0:-5]
print(i)
getRealUrl(index,i)
下一篇: python 类的初识