|
|
@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
import requests
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
myheaders = {
|
|
|
|
|
|
|
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0",
|
|
|
|
|
|
|
|
"Origin": "https://www.bilibili.com",
|
|
|
|
|
|
|
|
"Referer": "https://www.bilibili.com/video/",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cookies = {
|
|
|
|
|
|
|
|
'buvid3': 'DDA86D9C-4064-261D-2976-D4E63AD730A564738infoc',
|
|
|
|
|
|
|
|
'b_nut': '1695170764',
|
|
|
|
|
|
|
|
'i-wanna-go-back': '-1',
|
|
|
|
|
|
|
|
'b_ut': '7',
|
|
|
|
|
|
|
|
'_uuid': '2810F1671-99DE-10A66-C9AE-5B61019F2216163877infoc',
|
|
|
|
|
|
|
|
'buvid4': '87467447-EE1D-BC09-85DF-5A5E3F25BE7165649-023092008-b1nz50QSFWB7BaPFTf2tYA%3D%3D',
|
|
|
|
|
|
|
|
'buvid_fp': '266cc042522c26ce1e2557f010fbed18',
|
|
|
|
|
|
|
|
'rpdid': '|(JlRYJ)|~~k0J\'uYmlu~|)um',
|
|
|
|
|
|
|
|
'LIVE_BUVID': 'AUTO1216952190745314',
|
|
|
|
|
|
|
|
'hit-dyn-v2': '1',
|
|
|
|
|
|
|
|
'CURRENT_BLACKGAP': '0',
|
|
|
|
|
|
|
|
'FEED_LIVE_VERSION': 'V8',
|
|
|
|
|
|
|
|
'enable_web_push': 'DISABLE',
|
|
|
|
|
|
|
|
'header_theme_version': 'CLOSE',
|
|
|
|
|
|
|
|
'is-2022-channel': '1',
|
|
|
|
|
|
|
|
'fingerprint': '3e0ba62f2ede9954c9a3360a332ed3fe',
|
|
|
|
|
|
|
|
'home_feed_column': '5',
|
|
|
|
|
|
|
|
'browser_resolution': '1659-802',
|
|
|
|
|
|
|
|
'CURRENT_QUALITY': '112',
|
|
|
|
|
|
|
|
'PVID': '1',
|
|
|
|
|
|
|
|
'CURRENT_FNVAL': '4048',
|
|
|
|
|
|
|
|
'bili_ticket': 'eyJhbGciOiJIUzI1NiIsImtpZCI6InMwMyIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MjYxMzQ2MTcsImlhdCI6MTcyNTg3NTM1NywicGx0IjotMX0.0n5Yc4s1FwV1pzKnXIF2zfaxXNMWhOmLaJUn7BWcasY',
|
|
|
|
|
|
|
|
'bili_ticket_expires': '1726134557',
|
|
|
|
|
|
|
|
'b_lsid': '1010CFED5E_191D69F70D6',
|
|
|
|
|
|
|
|
'bp_t_offset_37785435': '975157412430348288',
|
|
|
|
|
|
|
|
'SESSDATA': 'faf21f25%2C1741437012%2Cc737f%2A92CjDRWap9qwrZzKXpPNWrsaDeI2PgC401HL-Krx6I2bhuhDGbh9sHwhaTc74Y5D6KA8QSVnV1bUdYQlE0RnNLRnVRVzdueFZRRlB6S2h5Rm04bEZMVUQ5TmF6eWhkeTVnbzUwZHEtMDBQU3JudmNnSnJyYmFMeGdnUVVMUjFDbXhfQ1FSVHRDR1pBIIEC',
|
|
|
|
|
|
|
|
'bili_jct': 'ce951c956d19b9d35b1dc373f2beb814',
|
|
|
|
|
|
|
|
'DedeUserID': '37785435',
|
|
|
|
|
|
|
|
'DedeUserID__ckMd5': '3bf0222f80269ba5',
|
|
|
|
|
|
|
|
'sid': '580krxex'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
param1 = {
|
|
|
|
|
|
|
|
"__refresh__": "true",
|
|
|
|
|
|
|
|
"page": "1",
|
|
|
|
|
|
|
|
"page_size": "42",
|
|
|
|
|
|
|
|
"pubtime_begin_s": "0",
|
|
|
|
|
|
|
|
"pubtime_end_s": "0",
|
|
|
|
|
|
|
|
"from_spmid": "333.337",
|
|
|
|
|
|
|
|
"platform": "pc",
|
|
|
|
|
|
|
|
"highlight": "1",
|
|
|
|
|
|
|
|
"single_column": "0",
|
|
|
|
|
|
|
|
"keyword": "2024巴黎奥运会",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
url = "https://api.bilibili.com/x/web-interface/search/all"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
obj1 = re.compile(r'{"type":"video".*?","arcurl":"(?P<ul>.*?)","aid":.*?"video_review":', re.S)
|
|
|
|
|
|
|
|
obj2 = re.compile(r',"dynamic":"","cid":(?P<cid>.*?),"dimension":', re.S)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 提取前8页视频的cid,并装入cid_list
|
|
|
|
|
|
|
|
cid_list = []
|
|
|
|
|
|
|
|
for i in range(1,9):
|
|
|
|
|
|
|
|
param1['page'] = i
|
|
|
|
|
|
|
|
resp1 = requests.get(url, headers=myheaders, cookies=cookies, params=param1)
|
|
|
|
|
|
|
|
result1 = obj1.finditer(resp1.text)
|
|
|
|
|
|
|
|
for it in result1:
|
|
|
|
|
|
|
|
ul1 = it.group('ul')
|
|
|
|
|
|
|
|
resp2 = requests.get(ul1, headers=myheaders, cookies=cookies)
|
|
|
|
|
|
|
|
result2 = obj2.finditer(resp2.text)
|
|
|
|
|
|
|
|
for itt in result2:
|
|
|
|
|
|
|
|
cid_list.append(itt.group('cid'))
|
|
|
|
|
|
|
|
print(f"cid = {itt.group('cid')} 已获取")
|
|
|
|
|
|
|
|
resp2.close()
|
|
|
|
|
|
|
|
time.sleep(0.05)
|
|
|
|
|
|
|
|
resp1.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 对前300个视频进行处理
|
|
|
|
|
|
|
|
first_300_cid = cid_list[:300]
|
|
|
|
|
|
|
|
for it in first_300_cid:
|
|
|
|
|
|
|
|
print(it)
|