|
|
|
@ -8,23 +8,23 @@ def get_video_ids(api_urls):
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
all_video_ids = []
|
|
|
|
|
# 设定计数器
|
|
|
|
|
cnt = 0
|
|
|
|
|
# 暴力查找
|
|
|
|
|
for page in range(1, 22):
|
|
|
|
|
# print(api_url)
|
|
|
|
|
# 执行翻页操作
|
|
|
|
|
api_url = api_urls + str(page)
|
|
|
|
|
# print(api_url)
|
|
|
|
|
# 获取Datas
|
|
|
|
|
response = requests.get(api_url, headers=headers)
|
|
|
|
|
response.encoding = 'utf-8'
|
|
|
|
|
Json = response.json()
|
|
|
|
|
# print(Json)
|
|
|
|
|
# print(Json['data'])
|
|
|
|
|
Datas = Json['data']['result']
|
|
|
|
|
for Data in Datas:
|
|
|
|
|
# 通过try except跳过B站设置的断点
|
|
|
|
|
try:
|
|
|
|
|
# print(Data)
|
|
|
|
|
bvids = Data['bvid']
|
|
|
|
|
print(bvids)
|
|
|
|
|
with open("bvid.txt", mode='a', encoding='utf-8') as f:
|
|
|
|
|
with open("bvid.txt", mode='a', encoding='utf-8') as f: # 执行写入操作
|
|
|
|
|
f.write(bvids + '\n')
|
|
|
|
|
cnt += 1
|
|
|
|
|
if (cnt == 300):
|
|
|
|
@ -42,4 +42,3 @@ def get_video_ids(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)
|
|
|
|
|
# save_video_ids_to_file(video_ids, 'bvid.txt')
|
|
|
|
|