Skip to content

Commit

Permalink
b站热播视频添加获取bv号的功能
Browse files Browse the repository at this point in the history
  • Loading branch information
RWGLQJ authored Sep 24, 2023
1 parent 53f8ec3 commit 40532bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions b站热播.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

app = Flask(__name__)

@app.route('/api/hot_videos', methods=['GET'])
def get_hot_videos():
try:
# 发送HTTP GET请求获取热播视频数据
url = 'https://api.bilibili.com/x/web-interface/popular'
response = requests.get(url)
data = response.json()

# 解析响应数据,提取热播视频信息
# 解析响应数据,提取热播视频信息(包括vb号)
hot_videos = []
for video in data['data']['list']:
title = video['title']
play_count = video['stat']['view']
hot_videos.append({'title': title, 'play_count': play_count})
vb_number = video['bvid']
hot_videos.append({'title': title, 'play_count': play_count, 'vb_number': vb_number})

return jsonify({'hot_videos': hot_videos})

Expand Down
6 changes: 4 additions & 2 deletions 总和.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,20 @@ def get_hot_videos():
response = requests.get(url)
data = response.json()

# 解析响应数据,提取热播视频信息
# 解析响应数据,提取热播视频信息(包括vb号)
hot_videos = []
for video in data['data']['list']:
title = video['title']
play_count = video['stat']['view']
hot_videos.append({'title': title, 'play_count': play_count})
vb_number = video['bvid']
hot_videos.append({'title': title, 'play_count': play_count, 'vb_number': vb_number})

return jsonify({'hot_videos': hot_videos})

except Exception as e:
return jsonify({'error': str(e)})


#邮箱发信api
#email = Flask(__name__)
SMTP_SERVER = 'smtp.qq.com'
Expand Down

0 comments on commit 40532bb

Please sign in to comment.