Cliqto-Media's picture
Upload 2 files
26bba14 verified
Raw History Blame Contribute Delete
7.69 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>YouTube Transcript Scraper</title>
<style>
:root{--bg:#fff;--fg:#1f2330;--muted:#5d6475;--line:#d9dce4;--card:#f6f7fa;--accent:#5b4bdb;--err:#b42318}
@media (prefers-color-scheme:dark){:root{--bg:#0f1117;--fg:#e8eaf0;--muted:#a3a9b8;--line:#2c3140;--card:#171a23;--accent:#8b7ff0;--err:#ff8a80}}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--fg);font:16px/1.5 system-ui,-apple-system,Segoe UI,Roboto,sans-serif}
main{max-width:760px;margin:0 auto;padding:24px 16px 48px}
h1{font-size:1.6rem;margin:0 0 4px}
p.lead{color:var(--muted);margin:0 0 20px}
label{display:block;font-weight:600;margin:16px 0 6px}
small{color:var(--muted);font-weight:400}
input,textarea,select{width:100%;padding:10px 12px;border:1px solid var(--line);border-radius:8px;background:var(--card);color:var(--fg);font:inherit}
textarea{min-height:84px;resize:vertical}
.row{display:flex;gap:12px;flex-wrap:wrap}.row>div{flex:1 1 200px}
button{margin-top:18px;padding:11px 18px;border:0;border-radius:8px;background:var(--accent);color:#fff;font:inherit;font-weight:600;cursor:pointer}
button[disabled]{opacity:.6;cursor:wait}
button.sec{background:transparent;color:var(--accent);border:1px solid var(--accent);margin-right:8px}
#status{margin-top:14px;color:var(--muted)}#status.err{color:var(--err)}
.video{margin-top:20px;padding:14px;border:1px solid var(--line);border-radius:10px;background:var(--card)}
.video h2{font-size:1rem;margin:0 0 6px;word-break:break-all}
.video pre{white-space:pre-wrap;max-height:320px;overflow:auto;margin:8px 0 0;font:14px/1.5 ui-monospace,Menlo,monospace}
.steps{background:var(--card);border:1px solid var(--line);border-radius:10px;padding:12px 16px;margin:0 0 8px}
.steps ol{margin:6px 0 0;padding-left:20px}
a{color:var(--accent)}
footer{margin-top:32px;color:var(--muted);font-size:.9rem}
</style>
</head>
<body>
<main>
<h1>YouTube Transcript Scraper</h1>
<p class="lead">Paste YouTube links, get the transcripts as text. Runs on Apify with your own token.</p>
<div class="steps"><strong>Your Apify token (once)</strong>
<ol>
<li>Sign up or log in at <a href="https://console.apify.com" target="_blank" rel="noopener noreferrer">console.apify.com</a> (free plan works).</li>
<li>Open <b>Settings → API &amp; Integrations</b> and copy your personal API token.</li>
<li>Paste it below. It stays in this tab, goes only to api.apify.com and is never saved.</li>
</ol></div>
<label for="token">Apify API token</label>
<input id="token" type="password" autocomplete="off" spellcheck="false" placeholder="Paste your own token">
<label for="urls">YouTube links or video IDs <small>(one per line, up to 5)</small></label>
<textarea id="urls">https://www.youtube.com/watch?v=jNQXAC9IVRw</textarea>
<div class="row">
<div><label for="lang">Language <small>(code, e.g. en, es, de)</small></label><input id="lang" value="en"></div>
<div><label for="kind">Caption type</label>
<select id="kind"><option value="MANUAL_FIRST">Manual first</option><option value="GENERATED_FIRST">Auto-generated first</option><option value="MANUAL_ONLY">Manual only</option><option value="GENERATED_ONLY">Auto-generated only</option></select></div>
</div>
<button id="run">Get transcripts</button>
<div id="status" role="status"></div>
<div id="out"></div>
<footer>
Runs are billed to your own Apify account at the Actor's price.
Actor details and price: <a href="https://cliqtomedia.com/actors/youtube-transcript-scraper/?utm_source=huggingface&utm_medium=template&utm_campaign=promo-2026-11" target="_blank" rel="noopener noreferrer">YouTube Transcript Scraper</a>.
More Actors by <a href="https://cliqtomedia.com/?utm_source=huggingface&utm_medium=template&utm_campaign=promo-2026-11" target="_blank" rel="noopener noreferrer">Cliqto Media</a>.
Need another site? The <a href="https://huggingface.co/spaces/cliqtomedia/apify-web-scraper" target="_blank" rel="noopener noreferrer">Apify Web Scraper</a> Space runs any of our 250+ scrapers with the same token.
</footer>
</main>
<script>
const ACTOR = 'cliqtomedia~youtube-transcript-scraper';
const $ = id => document.getElementById(id);
const statusEl = $('status'), out = $('out'), btn = $('run');
function setStatus(msg, err){ statusEl.textContent = msg; statusEl.className = err ? 'err' : ''; }
function download(name, text, type){
const a = document.createElement('a');
a.href = URL.createObjectURL(new Blob([text], {type}));
a.download = name; a.click(); setTimeout(() => URL.revokeObjectURL(a.href), 1000);
}
function render(items){
out.innerHTML = '';
if (!items.length){ setStatus('The run finished but returned no items.', true); return; }
items.forEach(it => {
const box = document.createElement('div'); box.className = 'video';
const h = document.createElement('h2'); h.textContent = it.canonicalUrl || it.videoId || it.normalizedInput || 'Video';
box.appendChild(h);
const meta = document.createElement('div');
if (it.status === 'SUCCEEDED'){
const lang = it.track && it.track.languageCode ? it.track.languageCode : '';
meta.textContent = `${it.segmentCount || 0} segments${lang ? ' · ' + lang : ''}`;
box.appendChild(meta);
const b1 = document.createElement('button'); b1.className = 'sec'; b1.textContent = 'Copy text';
b1.onclick = () => navigator.clipboard.writeText(it.text || '').then(() => b1.textContent = 'Copied');
const b2 = document.createElement('button'); b2.className = 'sec'; b2.textContent = 'Download TXT';
b2.onclick = () => download(`${it.videoId || 'transcript'}.txt`, it.text || '', 'text/plain');
const b3 = document.createElement('button'); b3.className = 'sec'; b3.textContent = 'Download JSON';
b3.onclick = () => download(`${it.videoId || 'transcript'}.json`, JSON.stringify(it, null, 2), 'application/json');
box.append(b1, b2, b3);
const pre = document.createElement('pre'); pre.textContent = it.text || ''; box.appendChild(pre);
} else {
const code = it.error && it.error.code ? it.error.code : it.status;
meta.textContent = `No transcript: ${code}`; meta.style.color = 'var(--err)';
box.appendChild(meta);
}
out.appendChild(box);
});
setStatus(`Done: ${items.length} video(s).`);
}
btn.onclick = async () => {
const token = $('token').value.trim();
const videoUrls = $('urls').value.split(/\s+/).map(s => s.trim()).filter(Boolean).slice(0, 5);
if (!token){ setStatus('Paste your own Apify API token first.', true); return; }
if (!videoUrls.length){ setStatus('Add at least one YouTube link or video ID.', true); return; }
const input = { videoUrls, preferredLanguages: [$('lang').value.trim() || 'en'], captionPreference: $('kind').value };
btn.disabled = true; out.innerHTML = ''; setStatus('Running on Apify… this usually takes under a minute.');
try {
const r = await fetch(`https://api.apify.com/v2/acts/${ACTOR}/run-sync-get-dataset-items?format=json&clean=true`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token },
body: JSON.stringify(input)
});
const body = await r.text();
if (!r.ok){
let msg = body; try { msg = JSON.parse(body).error.message; } catch(e) {}
setStatus(r.status === 401 ? 'Apify did not accept the token. Check that you copied it fully.' : `Apify error ${r.status}: ${msg}`, true);
return;
}
render(JSON.parse(body));
} catch (e) {
setStatus('Network error: ' + e.message, true);
} finally { btn.disabled = false; }
};
</script>
</body>
</html>