Created
October 6, 2023 17:53
-
-
Save techwiz37/4ca329c974650db745f3fa08a39d644c to your computer and use it in GitHub Desktop.
Scrape youtube downloader 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| 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