Skip to content

Commit

Permalink
Merge pull request #753 from mokurin000/main
Browse files Browse the repository at this point in the history
fix: apply WBI sign to search-* apis
  • Loading branch information
z0z0r4 authored Apr 28, 2024
2 parents 607510c + 0c9c5bc commit 209ab8d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
13 changes: 6 additions & 7 deletions bilibili_api/data/api/search.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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": {
Expand All @@ -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": "获取默认的搜索内容"
Expand All @@ -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,
Expand All @@ -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: 页码",
Expand Down Expand Up @@ -93,4 +92,4 @@
"comment": "搜索频道"
}
}
}
}
6 changes: 3 additions & 3 deletions bilibili_api/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 209ab8d

Please sign in to comment.