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中非常杂乱的,,看的头晕
  • 相关阅读:
    Vue中父子组件的通讯
    字符串svg代码转 base64 url
    Vue 中封装 websocket
    vue中使用Echarts,销毁原有的图表进行重新赋值
    Vue中常用表格(增删改查)
    刷新组件
    hdu1272小希的迷宫(并查集+判环)
    九余数定理
    Runtime Error可能的情况
    hdu2035 人见人爱A^B题解
  • 原文地址:https://www.cnblogs.com/Skyda/p/10028937.html
Copyright © 2011-2022 走看看