首页 编程教程正文

python抖X解析源码

piaodoo 编程教程 2020-02-22 22:04:41 916 0 python教程

本文来源吾爱破解论坛

本帖最后由 wushaominkk 于 2019-6-25 17:41 编辑

废话不多说,直接贴代码,粘上就能用!
博客粘过来的,无奈浏览器自动翻译了,没审核,贼尴尬。。。。已经更新:
[Python] 纯文本查看 复制代码

<pre style="background-color:#2b2b2b;color:#a9b7c6;font-family:'宋体';font-size:15.0pt;">import requests
import json
import logging
import re
from urllib import parse


def analysis_douying(share_url):
    try:
        response = requests.get(share_url, allow_redirects=False)
        aweme_id = re.findall('(\d+)', parse.urlparse(response.headers.get('Location')).path)[0]
    except Exception as e:
        logging.warning('错误的地址 {}'.format(e))
        return json.dumps({'status': 0, 'info': '错误的地址'})
    url = 'https://aweme.snssdk.com/aweme/v1/aweme/detail/'
    params = {
        "aweme_id": aweme_id,
        "origin_type": "web",
        "retry_type": "no_retry",
        "iid": "75186358813",
        "device_id": "68273753722",
        "ac": "wifi",
        "channel": "tengxun_new",
        "aid": "1128",
        "app_name": "aweme",
        "version_code": "660",
        "version_name": "6.6.0",
        "device_platform": "android",
        "ssmix": "a",
        "device_type": "OPPO R11",
        "device_brand": "OPPO ",
        "language": "zh",
        "os_api": "22",
        "os_version": "5.1.1",
        "uuid": "866174010180467",
        "openudid": "b42e992398373803",
        "manifest_version_code": "660",
        "resolution": "720*1280",
        "dpi": "240",
        "update_version_code": "6602",
        "_rticket": "1560432451284",
        "mcc_mnc": "46007",
        "js_sdk_version": "1.16.2.7",
        "ts": "1560432451"
    }
    headers = {
        'User-Agent': 'com.ss.android.ugc.aweme/660 (Linux; U; Android 5.1.1; zh_CN; OPPO R11; Build/NMF26X; Cronet/58.0.2991.0)'
    }
    response = requests.get(url=url, params=params, headers=headers)
    json_info = json.loads(response.text)
    try:
        title = json_info['aweme_detail']['desc']
        rel_video_url = json_info['aweme_detail']['video']['play_addr']['url_list'][0]
        return json.dumps({'status': 1, 'title': title, 'rel_video_url': rel_video_url})
    except Exception as e:
        logging.warning('解析失败: {}'.format(e))
        return json.dumps({'status': 0, 'info': '解析失败'})


if __name__ == '__main__':
    print(json.loads(analysis_douying('http://v.douyin.com/rqW8M5/')))

</pre>

版权声明:

本站所有资源均为站长或网友整理自互联网或站长购买自互联网,站长无法分辨资源版权出自何处,所以不承担任何版权以及其他问题带来的法律责任,如有侵权或者其他问题请联系站长删除!站长QQ754403226 谢谢。

有关影视版权:本站只供百度云网盘资源,版权均属于影片公司所有,请在下载后24小时删除,切勿用于商业用途。本站所有资源信息均从互联网搜索而来,本站不对显示的内容承担责任,如您认为本站页面信息侵犯了您的权益,请附上版权证明邮件告知【754403226@qq.com】,在收到邮件后72小时内删除。本文链接:https://www.piaodoo.com/7478.html

搜索