跳到正文
DEV Community· VNCNT LABS·· 3 小時前AI 評分58

YouTube Transcript Scraper 可按影片連結、關鍵字或頻道擷取字幕,每段影片 $0.005

YouTube transcript API: full text and timestamps from links, keyword searches or channels for $0.005 a video (Python, curl, MCP)

AI 導讀

VNCNT Labs 的 YouTube Transcript Scraper 可從影片連結、關鍵字搜尋或頻道擷取完整字幕及時間戳,每段字幕收費 $0.005。

正文

A friend asked me which ChatGPT tutorial to send her mom to. I typed "chatgpt tutorial for beginners" into YouTube and got five long videos back, 2 hours 40 minutes of them in total. I wasn't going to watch all of that to answer one text message. I wanted the words, with timestamps, so I could skim them, search them and hand them to a model.

So I ran my own Apify Actor, YouTube Transcript Scraper, on that search. Here's what came back, what it cost, the code, and where other transcript Actors on the Apify Store are simply better.

(The Store links here carry my Apify affiliate ID, so Apify pays me a small commission if you sign up through one.)

The run

This is the Actor's public keyword preset, unchanged:

{
  "keywords": ["chatgpt tutorial for beginners"],
  "maxVideosPerKeyword": 5,
  "excludeShorts": true
}

The search found 32 videos, none of the top ones were Shorts, and it queued the first 5. The run took 47 seconds and returned 6 rows: one summary row for the keyword and one transcript row per video. All 5 came back with captions, so all 5 were charged at $0.005. That's $0.025 for 31,701 words.

Rank Video Channel Length Words Views
1 ChatGPT for Beginners - 2026 Edition AI Mastermind 16 min 2,543 595,711
2 ChatGPT Tutorial: How to Use Chat GPT For Beginners Charlie Chang 27 min 6,253 4,984,364
3 ChatGPT Work Tutorial for Beginners Kevin Stratvert 9 min 1,766 65,944
4 FULL ChatGPT Tutorial For Beginners in 2026! (Become a PRO) AI Foundations 91 min 18,428 26,887
5 ChatGPT Tutorial for Beginners: How to Actually Get Work Done with AI Kevin Stratvert 14 min 2,711 110,648

Each transcript row has the full text, a segments list (start, duration, end, text in seconds), the caption language, title, channel, views, length and the search rank. For the record, my answer to the text message was video 1. It opens with "now I know how intimidating a new technology can be for somebody who's trying to learn especially if you're a little bit older", which is exactly the audience.

What the transcripts actually look like

Two things surprised me once I read the raw rows.

First, you can tell automatic captions from creator captions without being told. Kevin Stratvert's two videos come back as proper sentences: 161 and 164 segments, punctuation, no overlapping times. The AI Mastermind and Charlie Chang videos are lowercase with almost no punctuation, and nearly every segment overlaps the next one (349 of 363 and 833 of 837). That's YouTube's rolling auto captions. The text itself isn't duplicated, only the timing overlaps, so joining the segments gives you exactly the transcript field. But it also means auto captions spell things the way they hear them. Video 1 says "chat gbt" 22 times, and the 91-minute one has "ChatGBT" 52 times. If you search transcripts for a product name, search for the misspellings too.

Second, search order moves. I ran the same input again two minutes later for the code below and videos 4 and 5 had swapped places. If you're tracking rankings over time, store the searchRank with a date and don't treat one run as gospel.

A single video, with [mm:ss] lines

For one link I like the timestamped text field. It's one string with a timestamp in front of every line, which is the easiest thing to paste into notes or a prompt. This is the single-video preset on Steve Jobs' 2005 Stanford speech:

curl -sS -X POST "https://api.apify.com/v2/acts/vncntlabs~youtube-transcript-scraper/run-sync-get-dataset-items?maxTotalChargeUsd=0.01" \
  -H "Authorization: Bearer $APIFY_TOKEN" -H "Content-Type: application/json" \
  -d '{"videos":["https://www.youtube.com/watch?v=UF8uR6Z6KLc"],"includeSegments":false,"includeTimestampedText":true}' \
  | jq -r '.[0].timestampedTranscript' > jobs.txt

That took 24 seconds and wrote 244 lines (2,298 words). grep -n "Stay Hungry" jobs.txt finds [14:08] Beneath it were the words: "Stay Hungry. Stay Foolish." straight away, which is the kind of lookup I actually use this for.

One gap I should mention: for videos you pass as links, views and videoDurationSeconds come back empty. Those come from search results, so only keyword and channel rows have them.

Turning it into chunks for RAG

This is the Python I ran for the search above, with apify-client 3.x. In 3.x call() returns a Run object, so the dataset ID is run.default_dataset_id, not run["defaultDatasetId"]. It cuts every transcript into about 60 seconds of speech and keeps a link that opens the video at that second, so whatever answers your model gives can point back to the exact moment:

import os
from decimal import Decimal

from apify_client import ApifyClient

client = ApifyClient(os.environ["APIFY_TOKEN"])
run_input = {
    "keywords": ["chatgpt tutorial for beginners"],
    "maxVideosPerKeyword": 5,
    "excludeShorts": True,
}

# max_total_charge_usd caps what this run can cost you (pay-per-event)
run = client.actor("vncntlabs/youtube-transcript-scraper").call(
    run_input=run_input, max_total_charge_usd=Decimal("0.05")
)

chunks = []
for row in client.dataset(run.default_dataset_id).iterate_items():
    if row["type"] != "transcript" or row["status"] != "ok":
        continue  # skips the keyword summary row and videos without captions
    print(f"#{row['searchRank']} {row['title']} ({row['channelName']}): "
          f"{row['wordCount']:,} words, {row['videoDurationSeconds'] // 60} min")

    # about 60 seconds of speech per chunk, with a link that opens the video there
    text, start = [], None
    for seg in row["segments"]:
        start = seg["start"] if start is None else start
        text.append(seg["text"])
        if seg["end"] - start >= 60:
            chunks.append({"url": f"{row['url']}&t={int(start)}s", "text": " ".join(text)})
            text, start = [], None
    if text:
        chunks.append({"url": f"{row['url']}&t={int(start)}s", "text": " ".join(text)})

print(len(chunks), "chunks ready to embed")
print(chunks[0]["url"], chunks[0]["text"][:80])

It printed the five videos and 164 chunks ready to embed. From there it's whatever embedding model and vector store you already use. A Node version of the same call is in the repo linked below.

Videos without captions

Some videos simply have no captions, and those get a row with status: "no_captions" and charged: false. In a bigger test last week I ran 6 searches with 15 videos each: 86 of 90 had transcripts (96%), and the 4 without were TV documentaries and full episodes. That batch took 93 seconds. The longest video in it was 13 hours and still came back whole, at about 163,000 words.

The other public presets are a channel one (the 5 newest long videos from @veritasium) and a Spanish caption track of the same Stanford speech. The keyword preset is the one I'd start with.

What it cost

$0.005 per transcript delivered, no start fee. Fast mode (a priority queue for big batches on a tight timeout) is $0.008. The keyword run was $0.025 and the Stanford speech was $0.005. On Apify's free plan a run stops at 10 transcripts. On paid plans it goes up to 1,000 per run, and the max charge you set always wins.

How it compares with other Apify Actors

I checked these on the Apify API today (October 27, 2026). Prices are per 1,000 transcripts on the free Apify plan unless noted.

Actor Inputs Extras Price per 1,000
vncntlabs/youtube-transcript-scraper Links, IDs, keyword search (Shorts filter), channels Segments, [mm:ss] text, status row per video, up to 1,000 per run $5 ($8 fast mode); no captions, not charged
supreme_coder/youtube-transcript-scraper Links, channels, playlists, keyword search JSON, plain text, SRT, VTT; language fallback, translation $1 free plan, $0.70 Bronze and up
johnvc/YoutubeTranscripts Links (up to 100 per run), channels SRT, VTT, translation, auto vs manual flag, free language check $2.75 free plan, $2 Gold and up
starvibe/youtube-video-transcript One video, or one channel with a date range Likes, comments, subscriber count, auto-generated flag; free users 50 a day $5
pintostudio/youtube-transcript-scraper One video per run Timestamped segments in your language $10

Where they're better, plainly. If price per video is all you care about, supreme_coder is 5 to 7 times cheaper than mine and also does playlists and SRT files. johnvc's is about half my price, tells you whether captions are auto-generated (mine doesn't), translates, and has thousands of users and a 4.78 rating. Mine has 2 users. starvibe's gives you likes and comment counts that mine doesn't.

Where mine fits: keyword search with a Shorts filter and the search rank on every row, a ready-to-paste [mm:ss] text field, and a clear status row for every video, so you can see what was skipped and why. It reads transcripts through DataForSEO's YouTube API rather than scraping YouTube pages. I haven't tested the others on the same 90-video batch, so I'm not going to claim mine is more reliable.

Using it from an assistant

Add this to Claude, ChatGPT or Cursor as a remote MCP server. It loads only this Actor, and you sign in to Apify in the browser, so no token goes in the file:

{
  "mcpServers": {
    "apify": {
      "url": "https://mcp.apify.com/?tools=vncntlabs/youtube-transcript-scraper"
    }
  }
}

The tool shows up as vncntlabs--youtube-transcript-scraper. Something like "get transcripts of the top 3 videos for 'sourdough starter', skip Shorts, and tell me where they disagree" works fine.

Code: https://github.com/PravinrajV/vncntlabs-apify-examples/tree/main/05-youtube-transcripts

If you're feeding transcripts into a RAG setup, I'm curious what chunk size you landed on. 60 seconds worked for tutorials, but I suspect it's too short for interviews where one answer runs three minutes.


Disclosure: I build the Apify Actor used here (VNCNT Labs). Every number in this post comes from a real run on Oct 27, 2026 (plus the 90-video batch noted above from Oct 23), and the prices are Apify Store list prices checked that day.

來源:DEV Community · dev.to