使用Flask爬取抖音的視頻,生成api接口

短視頻爬蟲

使用Python來爬取短視頻鏈接,目前只分析了抖音的,用Flask生成了api接口,項(xiàng)目地址:ShortVideoSpider。配套客戶端詳見short_video_spider_client

需要的庫

  • Flask~=2.1.2
  • requests
  • pyOpenSSL

接口

單個視頻

  • 本地地址:http://ip:port/douyin/single?url=https://v.douyin.com/2jA2dGq/&is_origin=0
  • 線上地址:http://81.68.122.109:8080/douyin/single?url=https://v.douyin.com/2jA2dGq/&is_origin=0
    參數(shù)說明:
    url:分享的短視頻鏈接,可以直接使用復(fù)制內(nèi)容,會解析里面的鏈接
    
    is_origin: 是否需要原始返回數(shù)據(jù)(0為需要,1為不需要)
    
    返回數(shù)據(jù)(is_origin為0):
    {
    "code": 200,
    //cover_image_url 視頻封面的圖片地址
    "cover_image_url": "https://p3-sign.douyinpic.com/obj/tos-cn-i-dy/b3cc0713ff7c4ad58e989ad4b8fde693?x-expires=1659412800&x-signature=SxHpFcL6X9HpvAS005QMN%2BhPh2Q%3D&from=4257465056_large",
    //video_url 視頻無水印地址
    "video_url": "https://aweme.snssdk.com/aweme/v1/play/?video_id=v0200fg10000cb6l3ojc77u09nmstov0&ratio=720p&line=0"
    }
    
    返回數(shù)據(jù)(is_origin為1):
    抖音的詳細(xì)數(shù)據(jù),返回的數(shù)據(jù)太多,自己進(jìn)行測試。
    
    

多個視頻

  • 本地地址:http://ip:port/douyin/list?url=https://v.douyin.com/2YVVPR7/&is_origin=0&max_cursor=0
  • 線上地址:http://81.68.122.109:8080/douyin/list?url=https://v.douyin.com/2YVVPR7/&is_origin=0&max_cursor=0
    參數(shù)說明:(一次最多返回20條數(shù)據(jù))
    url:分享的用戶主頁鏈接,可以直接使用復(fù)制內(nèi)容,會解析里面的鏈接
    is_origin: 是否需要原始返回數(shù)據(jù)(0為需要,1為不需要)
    max_cursor:第一次為0,返回會有hasmore來確定是否有更多數(shù)據(jù),設(shè)置返回的max_cursor到下次的請求參數(shù)來請求下次的數(shù)據(jù)
    返回數(shù)據(jù)(is_origin為0):
    {
    "code": 200,
    //視頻封面圖片地址的列表
    "cover_image_url_list": [
       .....
    ],
    //描述信息
    "des": "",
    //是否有更多數(shù)據(jù)
    "has_more": true,
    //下次最大滑動距離
    "max_cursor": 1643624245000,
    //視頻無水印地址列表
    "video_url_list": [
       .....
     ]
    }
    
    請求的數(shù)據(jù)太多,自己進(jìn)行測試。
    

用戶信息

  • 本地地址:http://ip:port/douyin/user?url=https://v.douyin.com/2YVVPR7/
  • 線上地址:http://81.68.122.109:8080/douyin/user?url=https://v.douyin.com/2YVVPR7/
    參數(shù)說明:
    url:分享的用戶主頁鏈接,可以直接使用復(fù)制內(nèi)容,會解析里面的鏈接
    返回數(shù)據(jù):
    { "code": 200,
      "extra": {
       "logid": "20220715151907010209168157440162C9",
       "now": 1657869547000 },
      "status_code": 0,
      "user_info": {
       "avatar_larger": {
           "uri": "aweme-avatar/tos-cn-i-0813_8b7da88366bc40bba58e2f8bce0255c9",
           "url_list": [
               "https://p3.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-i-0813_8b7da88366bc40bba58e2f8bce0255c9.jpeg?from=2956013662",
               "https://p11.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-i-0813_8b7da88366bc40bba58e2f8bce0255c9.jpeg?from=2956013662",
               "https://p26.douyinpic.com/aweme/1080x1080/aweme-avatar/tos-cn-i-0813_8b7da88366bc40bba58e2f8bce0255c9.jpeg?from=2956013662"
           ]
       },
       "avatar_medium": {
           "uri": "aweme-avatar/tos-cn-i-0813_8b7da88366bc40bba58e2f8bce0255c9",
           "url_list": [
               "https://p3.douyinpic.com/aweme/720x720/aweme-avatar/tos-cn-i-0813_8b7da88366bc40bba58e2f8bce0255c9.jpeg?from=2956013662",
               "https://p11.douyinpic.com/aweme/720x720/aweme-avatar/tos-cn-i-0813_8b7da88366bc40bba58e2f8bce0255c9.jpeg?from=2956013662",
               "https://p26.douyinpic.com/aweme/720x720/aweme-avatar/tos-cn-i-0813_8b7da88366bc40bba58e2f8bce0255c9.jpeg?from=2956013662"
           ]
       },
       "avatar_thumb": {
           "uri": "aweme-avatar/tos-cn-i-0813_8b7da88366bc40bba58e2f8bce0255c9",
           "url_list": [
               "https://p3.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-i-0813_8b7da88366bc40bba58e2f8bce0255c9.jpeg?from=2956013662",
               "https://p11.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-i-0813_8b7da88366bc40bba58e2f8bce0255c9.jpeg?from=2956013662",
               "https://p26.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-i-0813_8b7da88366bc40bba58e2f8bce0255c9.jpeg?from=2956013662"
           ]
       },
       "aweme_count": 6,
       "card_entries": [],
       "custom_verify": "",
       "enterprise_verify_reason": "",
       "favoriting_count": 0,
       "follow_status": 0,
       "follower_count": 101,
       "followers_detail": null,
       "following_count": 239,
       "geofencing": null,
       "is_gov_media_vip": false,
       "is_mix_user": false,
       "mix_count": 0,
       "mix_info": null,
       "mplatform_followers_count": 101,
       "nickname": "十七??",
       "original_musician": {
           "digg_count": 0,
           "music_count": 0,
           "music_used_count": 0
       },
       "platform_sync_info": [],
       "policy_version": null,
       "sec_uid": "MS4wLjABAAAAsRIQ9howZwtPIsFFZhkMS6q2KIc4wLs5q7LlExJqUNA",
       "secret": 0,
       "short_id": "0",
       "show_favorite_list": false,
       "signature": "互關(guān)咯\n#中二病 #熬夜冠軍 #俄語廢物",
       "total_favorited": "263",
       "type_label": null,
       "uid": "405060254438335",
       "unique_id": "xsy897256134",
       "verification_type": 0
      }}    
    

免責(zé)聲明

本倉庫只為學(xué)習(xí)研究,如涉及侵犯個人或者團(tuán)體利益,請與我取得聯(lián)系,我將主動刪除一切相關(guān)資料,謝謝!

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容