抖音水印python源码

简介: 抖音水印python源码import hashlibimport base64import timeimport requestsimport jsonimport lxml.htmldef base64encode(text: str, reverse_map: bool = False) ...

抖音水印python源码

import hashlib
import base64
import time
import requests
import json
import lxml.html

def base64encode(text: str, reverse_map: bool = False) -> str:

if reverse_map is False:
    return base64.b64encode(text.encode()).decode()

base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="[::-1]

r = ""  # the result
c = 3 - len(text) % 3  # the length of padding
p = base64chars[-1] * c  # the padding
s = text + "\0" * c  # the text to encode

i = 0
while i < len(s):
    if i > 0 and ((i / 3 * 4) % 76) == 0:
        r = r + "\r\n"

    n = (ord(s[i]) << 16) + (ord(s[i + 1]) << 8) + ord(s[i + 2])

    n1 = (n >> 18) & 63
    n2 = (n >> 12) & 63
    n3 = (n >> 6) & 63
    n4 = n & 63

    r += base64chars[n1] + base64chars[n2] + base64chars[n3] + base64chars[n4]
    i += 3

return (r[0: len(r) - len(p)] + p).lower()

link = input('请粘贴抖音的链接:')

link = 'http://v.douyin.com/rgGpHL/'

t = '1560489959057'

t = time.time()

res = link.strip() + str(int(t))

r = base64encode(hashlib.md5(res.encode()).hexdigest(), True)
print(r)

answer = 'ztgon6ohn64k09=mntkpongmz60l060qz6nb0t/dn9ka'

data = {

'pageUrl': link,
't': t,
's': r,

}

response = requests.post('http://www.kaolajiexi.com/ajax/parse.php', data=data)

print(response.text)
u = json.loads(response.text)'data'['sourceUrl']
print(u)
headers = {

'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36'

}
text = requests.get(link, allow_redirects=True, headers=headers).text
dom = lxml.html.etree.HTML(text)
title = dom.xpath('//p[@class="desc"]/text()')[0]
name = dom.xpath('//p[@class="name nowrap"]/text()')0

with open(f'{name} - {title}.mp4', 'wb') as f:

f.write(requests.get(u).content)

 

作者:MuNian123
来源:CSDN
原文:https://blog.csdn.net/qq_42370150/article/details/92782779
版权声明:本文为博主原创文章,转载请附上博文链接!

相关文章
|
20天前
|
人工智能 机器人 测试技术
【python】python小游戏——开心消消乐(源码)【独一无二】
【python】python小游戏——开心消消乐(源码)【独一无二】
|
20天前
|
存储 人工智能 搜索推荐
【python】python用户管理系统[简易版](源码+报告)【独一无二】
【python】python用户管理系统[简易版](源码+报告)【独一无二】
|
20天前
|
存储 数据挖掘 数据库
【Python】python天气数据抓取与数据分析(源码+论文)【独一无二】
【Python】python天气数据抓取与数据分析(源码+论文)【独一无二】
|
1月前
|
数据安全/隐私保护 Python
Python3给图片添加水印
Python3给图片添加水印
61 1
|
2月前
|
存储 设计模式 Java
深入 Python 解释器源码,我终于搞明白了字符串驻留的原理!
深入 Python 解释器源码,我终于搞明白了字符串驻留的原理!
41 2
|
2月前
|
存储 算法 计算机视觉
用Python做了个图片识别系统(附源码)
用Python做了个图片识别系统(附源码)
|
2月前
|
数据采集 机器学习/深度学习 数据可视化
分享68个Python爬虫源码总有一个是你想要的
分享68个Python爬虫源码总有一个是你想要的
86 0
|
15天前
|
存储 定位技术 数据库
【python毕业设计】python基于Pygame的吃金币游戏设计与实现(源码+毕业论文)【独一无二】
【python毕业设计】python基于Pygame的吃金币游戏设计与实现(源码+毕业论文)【独一无二】
|
15天前
|
数据采集 存储 人工智能
【python】python汽车效能数据集—回归建模(源码+数据集)【独一无二】
【python】python汽车效能数据集—回归建模(源码+数据集)【独一无二】
|
15天前
|
人工智能 数据可视化 数据挖掘
【python】Python国内GDP经济总量数据分析可视化(源码+报告)【独一无二】
【python】Python国内GDP经济总量数据分析可视化(源码+报告)【独一无二】