Skip to content

Instantly share code, notes, and snippets.

@techwiz37
Created October 6, 2023 17:53
Show Gist options
  • Select an option

  • Save techwiz37/4ca329c974650db745f3fa08a39d644c to your computer and use it in GitHub Desktop.

Select an option

Save techwiz37/4ca329c974650db745f3fa08a39d644c to your computer and use it in GitHub Desktop.
Scrape youtube downloader 1
/*
2023 © Amirul Dev
recode sertakan sumber biar semangat update :)
custom request? silahkan donasi
wa: 085157489446
*/
import playwr from 'playwright'
const browser = await playwr.chromium.launch({
headless: false,
acceptDownloads: true, // permission download
downloadsPath: '@amiruldev' // path download
})
const context = await browser.newContext();
const page = await context.newPage();
// ubah ukuran
await page.setViewportSize({ width: 501, height: 700 });
await page.goto('https://10downloader.com/en/108')
// input url
await page.type('#video_url', 'https://www.youtube.com/watch?v=AXrKGwNvFyo')
// klik button download
await page.click('#search > form > div')
// menunggu element
await page.waitForSelector('#downloadPage > div > div > div.info.col-md-4 > span')
// element title
const elTitle = await page.$('#downloadPage > div > div > div.info.col-md-4 > span')
// get title
const title = await elTitle.textContent()
// element durasi
const elDur = await page.$('#downloadPage > div > div > div.info.col-md-4 > div')
// get teks durasi
const durasi = await elDur.textContent()
// element url download
const eldown = await page.$('#video-downloads > table:nth-child(3) > tbody > tr:nth-child(1) > td:nth-child(4) > a')
const link = await eldown.getAttribute('href')
console.log(`
title: ${title}
${durasi}
link download: ${link}`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment