我在这里使用Youtube Data API:
https://github.com/youtube/api-samples
具体来说,我在看:
https://github.com/youtube/api-samples/blob/master/python/search.py
在该文件中有:
search_response = youtube.search().list(
q=options.q,
part="id,snippet",
maxResults=options.max_results
).execute()
但是,最大结果是50。是我可以将参数更改为youtube.search()以获得方法51 -100、101-150等的一种方法吗?我似乎在文档中找不到它。谢谢!
最佳答案
您可以使用pageToken参数获取下一页:
pageToken string
The pageToken parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken and prevPageToken properties identify other pages that could be retrieved.
从第一个响应返回下一页id(
nextPageToken
),使用该id来获取下一页。{
"kind": "youtube#searchListResponse",
"etag": etag,
"nextPageToken": string,
"prevPageToken": string,
"regionCode": string,
"pageInfo": {
"totalResults": integer,
"resultsPerPage": integer
},
"items": [
search Resource
]
}
可以找到更多信息here
关于python - youtube数据API多个页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41178484/