字幕

按视频 ID 提取 YouTube 字幕和闭幕字幕,支持配置语言和字幕来源(自动生成或上传者提供)。

通过提供 YouTube 视频 ID 和一个 language_codeyoutube_subtitles 来源来获取 YouTube 视频的文字记录。

circle-exclamation

请求示例

下面的示例演示如何从上传者提供字幕的 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"
            }
        ]
    }'

我们的示例使用 Realtime 集成方法。如果您想使用 Proxy Endpoint, 或异步的 Push-Pull 集成,请参阅 Integration Methods 章节。

请求参数值

通用

参数
说明
默认值

source

设置要使用的爬虫。

youtube_subtitles

query

YouTube 视频 ID。

context: language_code

指定字幕的语言。可用值请参见 这里arrow-up-right. 注意: 如果提供的 language_code 在 YouTube 视频中没有匹配的字幕/隐藏式字幕时,结果返回一个 404 状态。

context: subtitle_origin

指定是否检索由……提供的字幕, auto_generateduploader_provided.

callback_url

您回调端点的 URL。 更多信息.

– 必填参数

最后更新于

这有帮助吗?