From 6080c22a3d9a35a0140803b76a301a7feadbe0e2 Mon Sep 17 00:00:00 2001 From: 522109452 <522109452@qq.com> Date: Fri, 14 Jun 2024 14:13:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20base=5Fconfig=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=8A=96=E9=9F=B3=E5=8F=91=E5=B8=83=E6=97=B6=E9=97=B4=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=20fix:=20=E6=8A=96=E9=9F=B3=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E6=9E=9A=E4=B8=BE=E5=80=BC=20fix:=20?= =?UTF-8?q?=E6=8A=96=E9=9F=B3offset=E8=AE=A1=E7=AE=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/base_config.py | 4 +++- media_platform/douyin/core.py | 4 ++-- media_platform/douyin/field.py | 5 ++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/config/base_config.py b/config/base_config.py index 4236572..fe7d61c 100644 --- a/config/base_config.py +++ b/config/base_config.py @@ -3,8 +3,10 @@ PLATFORM = "xhs" KEYWORDS = "python,golang" LOGIN_TYPE = "qrcode" # qrcode or phone or cookie COOKIES = "" -# 具体值参见media_platform.xxx.field下的枚举值,展示只支持小红书 +# 具体值参见media_platform.xxx.field下的枚举值,暂时只支持小红书 SORT_TYPE = "popularity_descending" +# 具体值参见media_platform.xxx.field下的枚举值,暂时只支持抖音 +PUBLISH_TIME_TYPE = 0 CRAWLER_TYPE = "search" # 爬取类型,search(关键词搜索) | detail(帖子详情)| creator(创作者主页数据) # 是否开启 IP 代理 diff --git a/media_platform/douyin/core.py b/media_platform/douyin/core.py index dde5d5b..33c280c 100644 --- a/media_platform/douyin/core.py +++ b/media_platform/douyin/core.py @@ -91,8 +91,8 @@ class DouYinCrawler(AbstractCrawler): continue try: posts_res = await self.dy_client.search_info_by_keyword(keyword=keyword, - offset=page * dy_limit_count, - publish_time=PublishTimeType.UNLIMITED + offset=page * dy_limit_count - dy_limit_count, + publish_time=PublishTimeType(config.PUBLISH_TIME_TYPE) ) except DataFetchError: utils.logger.error(f"[DouYinCrawler.search] search douyin keyword: {keyword} failed") diff --git a/media_platform/douyin/field.py b/media_platform/douyin/field.py index 0b06b23..ab9da9f 100644 --- a/media_platform/douyin/field.py +++ b/media_platform/douyin/field.py @@ -12,9 +12,8 @@ class SearchChannelType(Enum): class SearchSortType(Enum): """search sort type""" GENERAL = 0 # 综合排序 - LATEST = 1 # 最新发布 - MOST_LIKE = 2 # 最多点赞 - + MOST_LIKE = 1 # 最多点赞 + LATEST = 2 # 最新发布 class PublishTimeType(Enum): """publish time type"""