YouTube 字幕
了解如何使用 Web Scraper API 抓取 YouTube 视频的字幕(隐藏式字幕)。了解参数和实用示例。
您可以通过提供 YouTube 视频 ID 和一个 language_code 到 youtube_subtitles 源进行爬取。
字幕(closed captions)与稿本是分开的。要提取标准稿本,请使用 YouTube 转录 源进行爬取。
请求示例
下面的示例演示如何从上传者提供字幕的 YouTube 视频检索英文闭合字幕。
curl 'https://realtime.oxylabs.io/v1/queries' \
--user 'USERNAME:PASSWORD' \
-H 'Content-Type: application/json' \
-d '{
"source": "youtube_subtitles",
"query": "c4P_YuNnZ7U",
"context": [
{
"key": "language_code",
"value": "en"
},
{
"key": "subtitle_origin",
"value": "uploader_provided"
}
]
}'import requests
from pprint import pprint
# 构建负载。
payload = {
'source': 'youtube_subtitles',
'query': 'c4P_YuNnZ7U',
'context': [
{
'key': 'language_code',
'value': 'en'
},
{
'key': 'subtitle_origin',
'value': 'uploader_provided'
}
]
}
# 获取响应。
response = requests.request(
'POST',
'https://realtime.oxylabs.io/v1/queries',
auth=('username', 'password'),
json=payload,
)
# 打印包含结果的 JSON 响应。
pprint(response.json())我们的示例使用 Realtime 集成方法。如果您想使用 Proxy Endpoint, 或异步 Push-Pull 集成,请参阅 集成方法 部分。
请求参数值
通用
– 必需参数
最后更新于
这有帮助吗?

