For AI agents: a documentation index is available at /llms.txt
Skip to main content

Scrape YouTube Video Data

Extract title, channel, view count, likes, and upload date from a YouTube video page using stealth mode.

Prerequisites

Steps

YouTube renders all video metadata via JavaScript after the initial page load. A plain HTTP fetch returns almost no data. The examples below wait for the page to settle before reading, and route through stealth mode because YouTube actively detects plain browser automation.

Selector stability

YouTube's DOM selectors change periodically. If any field returns null or an empty string, inspect the live page with browser DevTools to find the updated selector.

Send the BQL mutation over HTTP to the stealth endpoint. No browser library or BQL IDE required.

1. Send the request

curl -X POST \
"https://production-sfo.browserless.io/stealth/bql?token=YOUR_API_TOKEN_HERE" \
-H "Content-Type: application/json" \
-d '{
"query": "mutation ScrapeYouTubeVideo { goto(url: \"https://www.youtube.com/watch?v=dQw4w9WgXcQ\", waitUntil: networkIdle) { status } waitForSelector(selector: \"h1.ytd-watch-metadata\", timeout: 10000) { time } title: text(selector: \"h1.ytd-watch-metadata yt-formatted-string\") channel: text(selector: \"ytd-channel-name yt-formatted-string a\") views: text(selector: \".ytd-video-view-count-renderer .view-count\") likes: text(selector: \"ytd-segmented-like-dislike-button-renderer yt-formatted-string\") uploadDate: text(selector: \"#info-strings yt-formatted-string\") }",
"variables": {}
}'

2. Check the output

{
"data": {
"goto": { "status": 200 },
"waitForSelector": { "time": 1243 },
"title": "Rick Astley - Never Gonna Give You Up (Official Music Video)",
"channel": "Rick Astley",
"views": "1,234,567,890 views",
"likes": "16M",
"uploadDate": "Oct 24, 2009"
}
}

Next steps