parent
310d5a801d
commit
71601a9a3d
@ -1,44 +0,0 @@
|
|||||||
import requests
|
|
||||||
|
|
||||||
|
|
||||||
def get_video_ids(api_urls):
|
|
||||||
headers = {
|
|
||||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0',
|
|
||||||
'Cookie': "buvid3=A208D8C8-62E0-8A2C-49DE-97075EC9AFF347900infoc; b_nut=1709605247; CURRENT_FNVAL=4048; _uuid=6B1712B5-E56D-39CF-2F4F-1109679B2275450779infoc; buvid4=56D339AE-65A3-9EB3-637F-1C6844E511FF48608-024030502-XZT8dGJQQGvpxEW%2FgPNaOA%3D%3D; rpdid=|(u))kkYu|Yk0J'u~|mY|lklu; DedeUserID=506426443; DedeUserID__ckMd5=3fc44628b47de972; enable_web_push=DISABLE; FEED_LIVE_VERSION=V8; header_theme_version=CLOSE; fingerprint=0eaa6f4de3c8e4fbb7ac2f6b2dbeeaf2; buvid_fp_plain=undefined; buvid_fp=0eaa6f4de3c8e4fbb7ac2f6b2dbeeaf2; LIVE_BUVID=AUTO2817161348895068; CURRENT_QUALITY=80; SESSDATA=c20b1ba2%2C1741679244%2C9fa32%2A91CjDmAy9_jeDRbsRQaSuk5MkfKaRAaVej6SEgP7hWsXGVhV2wJNMxhHCTMRpuUFBL-48SVlV2TDFTZk5Md2NCR2Fxc3doVDFtTGIycU1pd0dGcGt0UC1kLUZoVURHQTJmNGZVb1IxVlk5Zk4yRTl5cFdOMUpJN1JFNy1UZXpMWmQ5bzZjcWdQRzRBIIEC; bili_jct=cc779de17c4fba7ff039ca3e8573ad3d; bili_ticket=eyJhbGciOiJIUzI1NiIsImtpZCI6InMwMyIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MjYzODY0NzIsImlhdCI6MTcyNjEyNzIxMiwicGx0IjotMX0.X7nq8XaGsaZS0lUB42-EyN2Q4hPwUkSc4a9pGNkrqZY; bili_ticket_expires=1726386412; PVID=1; home_feed_column=5; browser_resolution=1699-943; sid=4mrblyq6; bp_t_offset_506426443=976262979962011648; b_lsid=691F191E_191E6B279BF"
|
|
||||||
}
|
|
||||||
|
|
||||||
all_video_ids = []
|
|
||||||
# 设定计数器
|
|
||||||
cnt = 0
|
|
||||||
# 暴力查找
|
|
||||||
for page in range(1, 22):
|
|
||||||
# 执行翻页操作
|
|
||||||
api_url = api_urls + str(page)
|
|
||||||
# 获取Datas
|
|
||||||
response = requests.get(api_url, headers=headers)
|
|
||||||
response.encoding = 'utf-8'
|
|
||||||
Json = response.json()
|
|
||||||
Datas = Json['data']['result']
|
|
||||||
for Data in Datas:
|
|
||||||
# 通过try except跳过B站设置的断点
|
|
||||||
try:
|
|
||||||
bvids = Data['bvid']
|
|
||||||
print(bvids)
|
|
||||||
with open("bvid.txt", mode='a', encoding='utf-8') as f: # 执行写入操作
|
|
||||||
f.write(bvids + '\n')
|
|
||||||
cnt += 1
|
|
||||||
if (cnt == 300):
|
|
||||||
break
|
|
||||||
except:
|
|
||||||
continue
|
|
||||||
if (cnt == 300):
|
|
||||||
break
|
|
||||||
# print(bvids)
|
|
||||||
|
|
||||||
return 1
|
|
||||||
|
|
||||||
|
|
||||||
# API URLs
|
|
||||||
api_urls = 'https://api.bilibili.com/x/web-interface/search/type?search_type=video&keyword=巴黎奥运会&page='
|
|
||||||
|
|
||||||
video_ids = get_video_ids(api_urls)
|
|
Loading…
Reference in new issue