2019最新去抖音水印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']['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][1:]

with open(f'{name} - {title}.mp4', 'wb') as f:
    f.write(requests.get(u).content)

 

在线教育多年教育经验 曾任职某里P7 主要从事数据挖掘和AI 有想法深入学习加qq:2586251002 

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页
实付 9.90元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值