我尝试根据 youtube search API 按国家/地区获取 YouTube 趋势,我可以将图表设置为“mostPopular”,本应返回趋势视频详细信息,但它不起作用,并返回错误
from googleapiclient.discovery import build
DEVELOPER_KEY = "XXXXXXXXX"
YOUTUBE_API_SERVICE_NAME = "youtube"
YOUTUBE_API_VERSION = "v3"
def youtube_search(max_results=5, order="relevance", token=None, location=None, location_radius=None,
regionCode=None):
youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION, developerKey=DEVELOPER_KEY)
search_response = youtube.search().list(
type="video",
pageToken=token,
order=order,
part="id,snippet", # Part signifies the different types of data you want
chart="mostPopular",
maxResults=max_results,
location=location,
locationRadius=location_radius,
regionCode = regionCode,
).execute()
print(search_response)
youtube_search(regionCode='IE')
有人可以帮忙吗?
最佳答案
图表是 Videos resource 上的一个参数,它在搜索资源上不可用。
关于python - 无法提供图表作为 youtube 搜索 API 的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59258157/