From 0c9c5bc5c496c3f92e568600509ac685ee99cb60 Mon Sep 17 00:00:00 2001 From: poly000 <1348292515a@gmail.com> Date: Sun, 28 Apr 2024 00:59:05 +0800 Subject: [PATCH] fix: search* apis were forced to wbi sign --- bilibili_api/data/api/search.json | 13 ++++++------- bilibili_api/search.py | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/bilibili_api/data/api/search.json b/bilibili_api/data/api/search.json index 234c8129..01b970ab 100644 --- a/bilibili_api/data/api/search.json +++ b/bilibili_api/data/api/search.json @@ -1,7 +1,7 @@ { "search": { "web_search": { - "url": "https://api.bilibili.com/x/web-interface/search/all/v2", + "url": "https://api.bilibili.com/x/web-interface/wbi/search/all/v2", "method": "GET", "verify": false, "params": { @@ -11,7 +11,7 @@ "comment": "在首页以关键字搜索,只指定关键字,其他参数不指定" }, "web_search_by_type": { - "url": "https://api.bilibili.com/x/web-interface/search/type", + "url": "https://api.bilibili.com/x/web-interface/wbi/search/type", "method": "GET", "verify": false, "params": { @@ -22,7 +22,7 @@ "comment": "搜索关键字时限定类型,可以指定排序号" }, "default_search_keyword": { - "url": "https://api.bilibili.com/x/web-interface/search/default", + "url": "https://api.bilibili.com/x/web-interface/wbi/search/default", "method": "GET", "verify": false, "comment": "获取默认的搜索内容" @@ -33,8 +33,7 @@ "verify": false, "comment": "获取热搜" }, - "app_hot_search_keywords": - { + "app_hot_search_keywords": { "url": "https://app.bilibili.com/x/v2/search/trending/ranking?limit=30", "method": "GET", "verify": false, @@ -61,7 +60,7 @@ "manga": { "url": "https://manga.bilibili.com/twirp/comic.v1.Comic/Search?device=pc&platform=web", "method": "POST", - "verify":true, + "verify": true, "data": { "key_word": "str: 搜索用的关键词", "page_num": "int: 页码", @@ -93,4 +92,4 @@ "comment": "搜索频道" } } -} +} \ No newline at end of file diff --git a/bilibili_api/search.py b/bilibili_api/search.py index de493a2b..da5a5c63 100644 --- a/bilibili_api/search.py +++ b/bilibili_api/search.py @@ -165,7 +165,7 @@ async def search(keyword: str, page: int = 1) -> dict: """ api = API["search"]["web_search"] params = {"keyword": keyword, "page": page} - return await Api(**api).update_params(**params).result + return await Api(**api, wbi=True).update_params(**params).result async def search_by_type( @@ -255,7 +255,7 @@ async def search_by_type( if debug_param_func: debug_param_func(params) api = API["search"]["web_search_by_type"] - return await Api(**api).update_params(**params).result + return await Api(**api, wbi=True).update_params(**params).result async def get_default_search_keyword() -> dict: @@ -266,7 +266,7 @@ async def get_default_search_keyword() -> dict: dict: 调用 API 返回的结果 """ api = API["search"]["default_search_keyword"] - return await Api(**api).result + return await Api(**api, wbi=True).result async def get_hot_search_keywords() -> dict: