吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 3661|回复: 20
收起左侧

[Python 转载] 抖音视频详情与无水印获取

[复制链接]
chengccc 发表于 2021-9-13 15:59
[Python] 纯文本查看 复制代码
import random
import sys
import requests
import re
import jsonpath


class Dy:
    def __init__(self, url_str):
        self.headers = {
            'User-Agent': 'com.ss.android.ugc.live/110400 (Linux; U; Android 7.0; zh_CN_'
        }

        self.url_str = url_str

    def get_item_id(self):
        """从分享链接中提取url"""
        url = re.findall(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', self.url_str)[
            0]
        res = requests.get(url)
        item_id = re.findall(r'\d+', res.url)[0]
        if item_id == '404':
            print('分享链接错误!')
            sys.exit()
        else:
            return item_id

    def play_count(self, item_id):
        """
        获取播放量
        :param item_id:
        :return:{"data":{"digg_count":,"play_count":,"share_count":,"user_bury":,"user_digg":},"extra":{"now":13位时间戳},"status_code":0}
        """
        url = 'https://api3-normal-c-lq.huoshan.com/hotsoon/item/reaction/_play/'

        params = {
            'iid': 756942400129936,
            'device_id': 69336530495,
            'channel': 'dc_samsung_1112_64',
            'aid': '1112',
            'app_name': 'live_stream',
            'version_code': '110600',
            'device_platform': 'android',
            'os_version': '7.0',
            'manifest_version_code': '110600',
            'hs_location_permission': 0,
        }

        data = {
            'item_id': item_id,
        }

        res = requests.post(url, headers=self.headers, data=data, params=params)
        json_obj = res.json()
        print('播放量:', json_obj['data']['play_count'])

    def info(self, item_id):
        """
        :param item_id:
        :return:
        """
        try:
            # 如果在火山和抖音都能查询到
            url = 'https://api3-normal-c-lq.huoshan.com/hotsoon/item/video/_get/'

            params = {
                'item_id': item_id,
                'language': 'zh',
            }

            res = requests.get(url=url, headers=self.headers, params=params)
            json_obj = res.json()

            digg_count = jsonpath.jsonpath(json_obj, "$..digg_count")[0]
            comment_count = jsonpath.jsonpath(json_obj, "$..comment_count")[0]
            share_count = jsonpath.jsonpath(json_obj, "$..share_count")[0]
            url_list = jsonpath.jsonpath(json_obj, "$..video.url_list")[0]
            nickname = jsonpath.jsonpath(json_obj, "$..nickname")[0]
            short_id_str = jsonpath.jsonpath(json_obj, "$..short_id_str")[0]
            title = jsonpath.jsonpath(json_obj, "$..description")[0]
            signature = jsonpath.jsonpath(json_obj, "$..signature")[0].replace('\n', '')
            print('点赞量: {}\n评论量: {}\n分享量: {}\n视频url: {}\n标题: {}\n作者: {}\n抖音号: {}\n个人简介: {}'.format(digg_count,
                                                                                                   comment_count,
                                                                                                   share_count,
                                                                                                   url_list[0], title,
                                                                                                   nickname,
                                                                                                   short_id_str,
                                                                                                   signature))
        except:
            # 只能在抖音查询到
            url = f'https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids={item_id}'
            res = requests.get(url=url, headers=self.headers)
            json_obj = res.json()

            digg_count = jsonpath.jsonpath(json_obj, "$..digg_count")[0]
            comment_count = jsonpath.jsonpath(json_obj, "$..comment_count")[0]
            share_count = jsonpath.jsonpath(json_obj, "$..share_count")[0]
            url_list = jsonpath.jsonpath(json_obj, "$..play_addr.url_list")[0][0]
            nickname = jsonpath.jsonpath(json_obj, "$..nickname")[0]
            short_id = jsonpath.jsonpath(json_obj, "$..short_id")[0]
            title = jsonpath.jsonpath(json_obj, "$..desc")[0]
            signature = jsonpath.jsonpath(json_obj, "$..signature")[0].replace('\n', '')
            print('点赞量: {}\n评论量: {}\n分享量: {}\n视频url: {}\n标题: {}\n作者: {}\n抖音号: {}\n个人简介: {}'.format(digg_count,
                                                                                                   comment_count,
                                                                                                   share_count,
                                                                                                   url_list.replace('playwm', 'play'), title,
                                                                                                   nickname,
                                                                                                   short_id, signature))


if __name__ == '__main__':
    url = input('输入分享链接:')
    s = Dy(url)
    ids = s.get_item_id()
    s.info(ids)

免费评分

参与人数 6吾爱币 +12 热心值 +5 收起 理由
夫子点灯 + 1 + 1 谢谢@Thanks!
苏紫方璇 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
wanfon + 1 + 1 用心讨论,共获提升!
kk1212 + 1 + 1 谢谢@Thanks!
hyltlll + 1 + 1 我很赞同!
lyk1115 + 1 我很赞同!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| chengccc 发表于 2021-9-14 11:05
流泪的小白 发表于 2021-9-13 18:15
想知道大佬怎么抓的包

火山那个装xp插件用低版本抓包,抖音那个接口是web端的
 楼主| chengccc 发表于 2021-9-13 17:41
易燃易爆炸 发表于 2021-9-13 17:22
啊这。。是发了个寂寞吗 怎么操作求解

配置好环境,右键运行不就行了
yanha520 发表于 2021-9-13 16:19
洪咸饭 发表于 2021-9-13 16:47
感觉是很有用的东西
易燃易爆炸 发表于 2021-9-13 17:22
啊这。。是发了个寂寞吗 怎么操作求解
流泪的小白 发表于 2021-9-13 18:15
想知道大佬怎么抓的包
hyltlll 发表于 2021-9-13 18:20
可用,謝謝分享。
Noth1ng 发表于 2021-9-13 18:27
直接小程序就可以无水印下载了啊
wanfon 发表于 2021-9-13 19:27
虽然不懂但必须支持
小白2021 发表于 2021-9-13 20:34
这个比较实用,有时候下载下来水印在上面的确不太好。可以去掉很完美。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-3-29 07:44

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表