mirror of
https://github.com/Evil0ctal/Douyin_TikTok_Download_API.git
synced 2025-04-22 13:26:44 +08:00
😈 Change Douyin cookie
This commit is contained in:
parent
749ea35cb7
commit
35034c05da
16
scraper.py
16
scraper.py
@ -2,27 +2,26 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
# @Author: https://github.com/Evil0ctal/
|
||||
# @Time: 2021/11/06
|
||||
# @Update: 2023/03/06
|
||||
# @Update: 2023/03/08
|
||||
# @Version: 3.3.0
|
||||
# @Function:
|
||||
# 核心代码,估值1块(๑•̀ㅂ•́)و✧
|
||||
# 用于爬取Douyin/TikTok数据并以字典形式返回。
|
||||
# input link, output dictionary.
|
||||
import random
|
||||
|
||||
|
||||
import re
|
||||
import os
|
||||
import time
|
||||
import urllib.parse
|
||||
|
||||
import execjs
|
||||
import aiohttp
|
||||
import platform
|
||||
import asyncio
|
||||
import traceback
|
||||
import configparser
|
||||
import urllib.parse
|
||||
|
||||
from typing import Union
|
||||
|
||||
import execjs
|
||||
from tenacity import *
|
||||
|
||||
|
||||
@ -264,15 +263,12 @@ class Scraper:
|
||||
|
||||
# 获取单个抖音视频数据/Get single Douyin video data
|
||||
@retry(stop=stop_after_attempt(4), wait=wait_fixed(7))
|
||||
async def get_douyin_video_data(self, video_id: str, s_v_web_id: str = None) -> Union[dict, None]:
|
||||
async def get_douyin_video_data(self, video_id: str) -> Union[dict, None]:
|
||||
"""
|
||||
:param video_id: str - 抖音视频id
|
||||
:param s_v_web_id: str - Example: "s_v_web_id=verify_leytkxgn_kvO5kOmO_SdMs_4t1o_B5ml_BUqtWM1mP6BF; "
|
||||
:return:dict - 包含信息的字典
|
||||
"""
|
||||
print('正在获取抖音视频数据...')
|
||||
if s_v_web_id:
|
||||
self.douyin_api_headers['cookie'] = s_v_web_id
|
||||
try:
|
||||
# 构造访问链接/Construct the access link
|
||||
api_url = f"https://www.douyin.com/aweme/v1/web/aweme/detail/?device_platform=webapp&aid=6383&channel=channel_pc_web&aweme_id={video_id}&pc_client_type=1&version_code=190500&version_name=19.5.0&cookie_enabled=true&screen_width=1344&screen_height=756&browser_language=zh-CN&browser_platform=Win32&browser_name=Evil0ctal&browser_version=110.0&browser_online=true&engine_name=Gecko&engine_version=109.0&os_name=Windows&os_version=10&cpu_core_num=128&device_memory=2333&platform=PC&webid=7158288523463362079"
|
||||
|
@ -2,7 +2,7 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
# @Author: https://github.com/Evil0ctal/
|
||||
# @Time: 2021/11/06
|
||||
# @Update: 2023/02/19
|
||||
# @Update: 2023/03/08
|
||||
# @Version: 3.1.5
|
||||
# @Function:
|
||||
# 创建一个接受提交参数的FastAPi应用程序。
|
||||
@ -12,7 +12,6 @@
|
||||
import os
|
||||
import time
|
||||
import json
|
||||
|
||||
import aiohttp
|
||||
import uvicorn
|
||||
import zipfile
|
||||
@ -291,7 +290,7 @@ async def hybrid_parsing(request: Request, url: str, minimal: bool = False):
|
||||
# 获取抖音单个视频数据/Get Douyin single video data
|
||||
@app.get("/douyin_video_data/", response_class=ORJSONResponse, response_model=API_Video_Response, tags=["Douyin"])
|
||||
@limiter.limit(Rate_Limit)
|
||||
async def get_douyin_video_data(request: Request, douyin_video_url: str = None, video_id: str = None, s_v_web_id: str = None):
|
||||
async def get_douyin_video_data(request: Request, douyin_video_url: str = None, video_id: str = None):
|
||||
"""
|
||||
## 用途/Usage
|
||||
- 获取抖音用户单个视频数据,参数是视频链接|分享口令
|
||||
@ -335,7 +334,7 @@ async def get_douyin_video_data(request: Request, douyin_video_url: str = None,
|
||||
start_time = time.time()
|
||||
print('获取到的video_id数据:{}'.format(video_id))
|
||||
if video_id is not None:
|
||||
video_data = await api.get_douyin_video_data(video_id=video_id, s_v_web_id=s_v_web_id)
|
||||
video_data = await api.get_douyin_video_data(video_id=video_id)
|
||||
if video_data is None:
|
||||
result = {
|
||||
"status": "failed",
|
||||
|
Loading…
x
Reference in New Issue
Block a user