From 576c8e8d9f9d5f28f1e5dfb916a5a51c9dfc3db4 Mon Sep 17 00:00:00 2001 From: xueyueben <> Date: Thu, 13 Jun 2024 11:46:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=8A=96=E9=9F=B3?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E5=8F=91=E5=B8=83=E6=97=B6=E9=97=B4=E5=92=8C?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E5=A4=B1=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- media_platform/douyin/client.py | 14 ++++++++++---- media_platform/douyin/field.py | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/media_platform/douyin/client.py b/media_platform/douyin/client.py index ede6049..97722e0 100644 --- a/media_platform/douyin/client.py +++ b/media_platform/douyin/client.py @@ -2,6 +2,7 @@ import asyncio import copy import urllib.parse from typing import Any, Callable, Dict, List, Optional +import json import execjs import httpx @@ -119,14 +120,19 @@ class DOUYINClient(AbstractApiClient): params = { "keyword": urllib.parse.quote(keyword), "search_channel": search_channel.value, - "sort_type": sort_type.value, - "publish_time": publish_time.value, "search_source": "normal_search", - "query_correct_type": "1", - "is_filter_search": "0", + "query_correct_type": 1, + "is_filter_search": 0, "offset": offset, "count": 10 # must be set to 10 } + if sort_type != SearchSortType.GENERAL or publish_time != PublishTimeType.UNLIMITED: + params["filter_selected"] = urllib.parse.quote(json.dumps({ + "sort_type": str(sort_type.value), + "publish_time": str(publish_time.value) + })) + params["is_filter_search"] = 1 + params["search_source"] = "tab_search" referer_url = "https://www.douyin.com/search/" + keyword referer_url += f"?publish_time={publish_time.value}&sort_type={sort_type.value}&type=general" headers = copy.copy(self.headers) diff --git a/media_platform/douyin/field.py b/media_platform/douyin/field.py index 2ac4d62..0b06b23 100644 --- a/media_platform/douyin/field.py +++ b/media_platform/douyin/field.py @@ -20,5 +20,5 @@ class PublishTimeType(Enum): """publish time type""" UNLIMITED = 0 # 不限 ONE_DAY = 1 # 一天内 - ONE_WEEK = 2 # 一周内 - SIX_MONTH = 3 # 半年内 + ONE_WEEK = 7 # 一周内 + SIX_MONTH = 180 # 半年内