Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Puppeteer search youtube
const puppeteer = require('puppeteer')
const screenshot = 'youtube_fm_dreams_video.png'
try {
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.goto('')
await page.type('#search', 'Fleetwood Mac Dreams')
await page.waitForSelector('ytd-thumbnail.ytd-video-renderer')
await page.screenshot({
path: 'youtube_fm_dreams_list.png'
const videos = await page.$$('ytd-thumbnail.ytd-video-renderer')
await videos[2].click()
await page.waitForSelector('.html5-video-container')
await page.waitFor(5000)
await page.screenshot({
path: screenshot
await browser.close()
console.log('See screenshot: ' + screenshot)
} catch (err) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment