-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
165 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# 2.0.5 | ||
* 新增 User-Agent 配置项 | ||
* 优化获取动态数据 | ||
* 新增获取B站up数据的随机延迟配置项 | ||
* 新增puppeteer渲染图片测试脚本 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
import Config from '@/utils/config'; | ||
|
||
class BiliApi { | ||
biliConfigData: any; | ||
USER_AGENT: string; | ||
constructor() { | ||
this.biliConfigData = Config.getUserConfig('bilibili', 'config'); | ||
this.USER_AGENT = BiliApi.BILIBILI_USER_AGENT; | ||
this.initialize(); | ||
} | ||
|
||
static BILIBILI_USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36'; | ||
|
||
//初始化User-Agent | ||
async initialize() { | ||
await this.initUserAgent(); | ||
} | ||
async initUserAgent() { | ||
const userAgentList = await this.biliConfigData.userAgentList; | ||
if (userAgentList && userAgentList.length > 0) { | ||
const randomIndex = Math.floor(Math.random() * userAgentList.length); | ||
this.USER_AGENT = String(userAgentList[randomIndex]); | ||
} | ||
} | ||
|
||
// 将静态常量赋值给实例属性 | ||
get BILIBIL_API() { | ||
return { | ||
//获取动态资源列表 wbi/无wbi parama = { host_mid: uid, timezone_offset: -480, platform: 'web', features: 'itemOpusStyle,listOnlyfans,opusBigCover,onlyfansVote', web_location: "333.999", ...getDmImg(), "x-bili-device-req-json": { "platform": "web", "device": "pc" }, "x-bili-web-req-json": { "spm_id": "333.999" }, w_rid, wts } | ||
biliDynamicInfoList: `https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space`, | ||
|
||
//获取关注数与粉丝数 parama = { vmid: uid } | ||
biliUpFollowFans: `https://api.bilibili.com/x/relation/stat`, | ||
|
||
//通过uid获取up详情 parama = { mid: uid, jsonp: jsonp } | ||
biliSpaceUserInfo: `https://api.bilibili.com/x/space/acc/info`, | ||
|
||
//parama = { mid: uid, token: '',platform: 'web', web_location: 1550101, w_webid, w_rid, wts } | ||
biliSpaceUserInfoWbi: `https://api.bilibili.com/x/space/wbi/acc/info`, | ||
|
||
//通过关键词${upKeyword}搜索up主 parama = { keyword: 'upKeyword', page: 1, search_type: 'bili_user', order: 'totalrank', pagesize: 5 } | ||
biliSearchUp: `https://api.bilibili.com/x/web-interface/search/type`, | ||
//通过关键词${upKeyword}搜索up主 parama = { keyword: 'upKeyword', page: 1, search_type: 'bili_user', order: 'totalrank' },需要wbi签名 | ||
biliSearchUpWbi: `https://api.bilibili.com/x/web-interface/wbi/search/type`, | ||
|
||
biliLiveStatus: 'https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids', | ||
biliCard: 'https://api.bilibili.com/x/web-interface/card', | ||
biliStat: 'https://api.bilibili.com/x/relation/stat', | ||
biliLiveUserInfo: 'https://api.live.bilibili.com/live_user/v1/Master/info', | ||
biliOpusDetail: 'https://api.bilibili.com/x/polymer/web-dynamic/v1/opus/detail' | ||
}; | ||
} | ||
|
||
/**header */ | ||
get BILIBILI_HEADERS() { | ||
return { | ||
'Accept': '*/*', | ||
'Accept-Language': 'zh-CN,en-US;q=0.5', | ||
'Connection': 'keep-alive', | ||
'Accept-Encoding': 'gzip, deflate, br, zstd', | ||
'Cookie': '', | ||
'pragma': 'no-cache', | ||
'Cache-control': 'max-age=0', | ||
'DNT': '1', | ||
'Sec-GPC': '1', | ||
'sec-ch-ua-platform': '', | ||
'sec-ch-ua-mobile': '?0', | ||
'Sec-Fetch-Dest': 'empty', | ||
'Sec-Fetch-Mode': 'cors', | ||
'Sec-Fetch-Site': 'same-site', | ||
'Sec-Fetch-User': '?0', | ||
'Priority': 'u=4', | ||
'TE': 'trailers', | ||
'User-Agent': this.USER_AGENT | ||
}; | ||
} | ||
|
||
/**Login header */ | ||
get BIlIBILI_LOGIN_HEADERS() { | ||
return { | ||
'Accept': '*/*', | ||
'Accept-Language': 'zh-CN,en-US;q=0.5', | ||
'Accept-Encoding': 'gzip, deflate, br, zstd', | ||
'DNT': '1', | ||
'Sec-GPC': '1', | ||
'Upgrade-Insecure-Requests': '1', | ||
'Sec-Fetch-Dest': 'document', | ||
'Sec-Fetch-Mode': 'navigate', | ||
'Sec-Fetch-Site': 'none', | ||
'Sec-Fetch-User': '?1', | ||
'TE': 'trailers' | ||
}; | ||
} | ||
|
||
/**FullArticle header */ | ||
get BILIBILI_ARTICLE_HEADERS() { | ||
return { | ||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8', | ||
'Accept-Language': 'zh-CN,en-US;q=0.5', | ||
'Accept-Encoding': 'gzip, deflate, br, zstd', | ||
'Content-type': 'text/html; charset=utf-8', | ||
'Cookie': '', | ||
'pragma': 'no-cache', | ||
'Cache-control': 'no-cache', | ||
'DNT': '1', | ||
'Sec-GPC': '1', | ||
'sec-ch-ua-mobile': '?0', | ||
'Sec-Fetch-Dest': 'document', | ||
'Sec-Fetch-Mode': 'navigate', | ||
'Sec-Fetch-Site': 'same-site', | ||
'Sec-Fetch-User': '?1', | ||
'TE': 'trailers', | ||
'Upgrade-Insecure-Requests': '1', | ||
'User-Agent': this.USER_AGENT | ||
}; | ||
} | ||
|
||
get BILIBILI_DYNAMIC_SPACE_HEADERS() { | ||
return { | ||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', | ||
'Accept-Encoding': 'gzip, deflate, br, zstd', | ||
'Accept-Language': 'zh-CN,en-US;q=0.5', | ||
'Connection': 'keep-alive', | ||
'Priority': 'u=0, i', | ||
'Sec-Fetch-Dest': 'document', | ||
'Sec-Fetch-Mode': 'navigate', | ||
'Sec-Fetch-Site': 'none', | ||
'Sec-Fetch-User': '?1', | ||
'Sec-GPC': '1', | ||
'Upgrade-Insecure-Requests': '1', | ||
'User-Agent': this.USER_AGENT | ||
}; | ||
} | ||
} | ||
|
||
export default new BiliApi(); |
10 changes: 5 additions & 5 deletions
10
models/bilibili/bilibili.get.web.data.ts → ...ls/bilibili/bilibili.main.get.web.data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
models/bilibili/bilibili.query.ts → models/bilibili/bilibili.main.query.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
models/bilibili/bilibili.ticket.ts → models/bilibili/bilibili.risk.ticket.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
models/bilibili/bilibili.w_webid.ts → models/bilibili/bilibili.risk.w_webid.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters