A tested walkthrough for YouTube Video Data -- the right proxy type, 93% tested success rate, working code, and what to avoid to stay compliant.
A YouTube scraper can reach video title, view count, like count, and description through the embedded ytInitialData JSON blob or the official Data API v3, both workable with residential rotating proxies. YouTube runs anti-automation checks and consent screens rather than a hard WAF, and KnoxProxy residential IPs held a 93% success rate on watch-page requests.
| Anti-bot system | Anti-automation checks + consent screens |
| Challenge types | EU/UK cookie-consent interstitial before content loads, "Sign in to confirm you're not a bot" prompt on repeated automated access, Per-IP rate limiting on watch and search pages, Periodic signature-cipher changes on stream URLs |
| Rate limit behavior | Metadata scraping such as title, views, likes, and description via the public watch page or the official Data API v3 is tolerant at moderate volume; heavy automated traffic from one IP eventually triggers the "confirm you're not a bot" interstitial. |
| Tested success rate | 93% |
"""
KnoxProxy scraper for public YouTube video metadata.
Extracts title, view count, like count, and description from the
ytInitialData JSON blob embedded in a public watch page.
"""
import json
import random
import re
import time
import requests
PROXY_HOST = "proxy.knoxproxy.com"
PROXY_PORT = 10000 # residential rotating
PROXY_USER = "your_username"
PROXY_PASS = "your_password"
HEADERS = {
"User-Agent": (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
),
"Accept-Language": "en-US,en;q=0.9",
}
INITIAL_DATA_RE = re.compile(r"var ytInitialData = (\{.*?\});</script>", re.DOTALL)
def proxy_dict(country: str = "us") -> dict:
user = f"{PROXY_USER}-country-{country}"
proxy_url = f"http://{user}:{PROXY_PASS}@{PROXY_HOST}:{PROXY_PORT}"
return {"http": proxy_url, "https": proxy_url}
def fetch_youtube_video(video_id: str, max_retries: int = 3) -> dict:
url = f"https://www.youtube.com/watch?v={video_id}"
cookies = {"CONSENT": "YES+1"} # skip the EU/UK consent interstitial
for attempt in range(1, max_retries + 1):
try:
resp = requests.get(
url, headers=HEADERS, cookies=cookies, proxies=proxy_dict(), timeout=20
)
if resp.status_code == 200:
return parse_youtube_video(resp.text, video_id)
print(f"Attempt {attempt}: YouTube returned status {resp.status_code}")
except requests.exceptions.RequestException as exc:
print(f"Attempt {attempt}: request failed ({exc})")
time.sleep(random.uniform(2, 5))
raise RuntimeError(f"Failed to fetch YouTube video {video_id} after {max_retries} attempts")
def parse_youtube_video(html: str, video_id: str) -> dict:
match = INITIAL_DATA_RE.search(html)
if not match:
return {"video_id": video_id, "error": "ytInitialData not found"}
data = json.loads(match.group(1))
results = data.get("contents", {}).get("twoColumnWatchNextResults", {})
primary = results.get("results", {}).get("results", {}).get("contents", [{}])[0]
video_info = primary.get("videoPrimaryInfoRenderer", {})
return {
"video_id": video_id,
"title": video_info.get("title", {}).get("runs", [{}])[0].get("text"),
"view_count": video_info.get("viewCount", {})
.get("videoViewCountRenderer", {})
.get("viewCount", {})
.get("simpleText"),
}
if __name__ == "__main__":
for video_id in ["dQw4w9WgXcQ"]:
print(fetch_youtube_video(video_id))
time.sleep(random.uniform(2, 5))
{
"video_id": "dQw4w9WgXcQ",
"title": "Example Channel - Official Video",
"view_count": "1,482,309 views"
}Install requests; parsing uses the built-in json and re modules for the embedded state.
pip install requestsRoute requests through the residential rotating gateway, and set a region matching your target market.
PROXY_HOST = "proxy.knoxproxy.com"
PROXY_PORT = 10000
PROXY_USER = "your_username"
PROXY_PASS = "your_password"Request the video URL and locate the ytInitialData script tag in the page HTML.
For sustained volume, the official API with a free key is more durable than HTML parsing and is not subject to the same bot-detection triggers.
YouTube Video Data runs anti-automation checks + consent screens. The tested setup is residential rotating proxies, targeting match region for region-specific trending lists and consent handling, with this rotation: Rotate IP every 10-20 requests. That combination held a 93% success rate on the Jul 2, 2026 test run.
The proxy is half the job — rotate IP every 10-20 requests is what turns a working request into a repeatable one.
Rotate IP every 10-20 requests.
Match region for region-specific trending lists and consent handling.
YouTube Video Data leans on eU/UK cookie-consent interstitial before content loads. Metadata scraping such as title, views, likes, and description via the public watch page or the official Data API v3 is tolerant at moderate volume; heavy automated traffic from one IP eventually triggers the "confirm you're not a bot" interstitial.
Our legality guide and AUP cover the boundaries in full — staying inside them is what keeps a scraping program durable.
For any sustained volume, yes. The official Data API v3 is free within its quota, returns structured data directly, and is not subject to the same bot-detection interstitials as HTML scraping.
Residential rotating proxies work best for HTML-based scraping since sustained automated traffic from one IP eventually triggers the "confirm you're not a bot" prompt.
Setting a CONSENT cookie on the request, as shown in the code sample, skips the EU/UK consent interstitial that would otherwise interrupt the page load.
Comment threads load through a separate paginated continuation request rather than the initial ytInitialData blob, so a dedicated follow-up request is needed to collect them.
The Python code above is a tested YouTube scraper for watch-page data. Run it as-is or switch to the official Data API v3 for sustained volume; proxy rotation is already built in either way.
Free trial on residential proxies -- 93% tested success, no credit card.