24 lines
666 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import requests
# 1. 公共 API 地址(无需 token
endpoint = 'https://api.dailymotion.com/videos'
# 2. 构造查询参数:
# - search搜索关键词
# - fields只取 id 和 title 两个字段
# - limit最多返回 5 条
params = {
'search': '郭德纲',
'fields': 'id,title,created_time,thumbnail_240_url,duration,owner.id,owner.screenname,likes_total,views_total,owner.avatar_60_url,owner.followers_total,owner.videos_total',
'limit': 5,
'page': 2,
'sort': "relevance"
}
# 3. 发起 GET 请求
response = requests.get(endpoint, params=params)
# 4. 将结果转为 JSON 并打印
data = response.json()
print(data)