zoukankan      html  css  js  c++  java
  • 练手_抓取手机抖音视频

    # python 3.7
    import requests,json
    
    class Douyin(object):
        def __init__(self):
            self.staticurl='https://api-eagle.amemv.com/aweme/v1/feed/?type=0&max_cursor=0&min_cursor=6&count=10&volume=0.7333333333333333&pull_type=0&need_relieve_aweme=0&filter_warn=0&req_from&is_cold_start=1&ts=1543312383&js_sdk_version=&app_type=normal&openudid=6052045542457820&version_name=3.4.0&device_type=I9200&ssmix=a&iid=52408672063&os_api=19&device_id=59880078301&resolution=800*1280&device_brand=samsung&aid=1128&manifest_version_code=340&app_name=aweme&_rticket=1543312384166&os_version=4.4.4&device_platform=android&version_code=340&update_version_code=3402&ac=wifi&dpi=213&uuid=862758504291428&language=zh&channel=wandoujia_zhiwei&as=a105011f6fefdba30d4255&cp=19ffbe56f2d3f138e1Wk_o&mas=01417d11bddffd70cd989221ac6b9e82a3acac4c2c260ccc864626'
            self.headers={'Cookie': 'install_id=52408672063; ttreq=1$37fc7dc4dd5da0b8eaae3a85fd59c2ca7b8a5c9b; odin_tt=4a1b12b617d2cd8a022b8c18280532cd8432c57e55a7551ed09e0da2926ef593afad26bc94fc5fc4f30c4975136aa369',
                          'User-Agent': 'com.ss.android.ugc.aweme/340 (Linux; U; Android 4.4.4; zh_CN; I9200; Build/KTU84P; Cronet/58.0.2991.0)'
            }
    
        def parse(self):
            rep = requests.get(url=self.staticurl,headers=self.headers)
            rep.encoding='utf8'
            r_list = json.loads(rep.text)
            print(r_list)
            for i in r_list["aweme_list"]:
                name = i['desc']
                href = i['video']['play_addr']['url_list'][0]
                print(name,href)
                res = requests.get(url=href,stream=True,headers = self.headers)
                if res.status_code==200:
                    with open('%s.txt'%name,'wb') as f:
                        f.write(res.content)
                    print('成功一个')
    
        def write(self):
            pass
    
        def wordon(self):
            pass
    
    if __name__ == '__main__':
        d = Douyin()
        d.parse()
    View Code————就是在返回的json中非常杂乱的,,看的头晕
  • 相关阅读:
    jq省份城市区街道数据整理成树型json并放到页面供网友选择
    python2爬取国家统计局全国省份城市区街道信息
    mp4视频中插入文字
    wap视频广告遇到的问题
    vscode(Visual Studio Code)中安装Debugger for Chrome插件调试页面
    学习node.js的一些笔记
    gulp打开gbk编码的html文件乱码
    解决[Errno 10048]报错
    MyBatis学习总结(一)
    Java学习之软件安装
  • 原文地址:https://www.cnblogs.com/Skyda/p/10028937.html
Copyright © 2011-2022 走看看