Skip to content

harusame3144/youtube-related-scraper

 
 

Repository files navigation

youtube-related-scraper

Build Status npm version Codacy Badge
NPM

Example Code

  • Using Promise
const { Client } = require('@sirubot/yt-related-scraper')
Client.get('https://www.youtube.com/watch?v=AufydOsiD6M')
.then(results => {
    console.log(`Scraped ${results.length} related videos`)
    console.log(results)
})
.catch((e) => {
    console.log('An Error appeared')
    console.log(e.stack)
})
  • Using Await/Async
const { Client } = require('@sirubot/yt-related-scraper')
async function getRelated (url) {
    try {
    const results = await Client.get(url)
    console.log(`Scraped ${results.length} related videos`)
    console.log(results)
    } catch (e) {
        console.log('An Error appeared')
        console.log(e.stack)
    }
}
  • IP Binding Support (RoutePlanner)
const { Client, RoutePlanner } = require('@sirubot/yt-related-scraper')
const routePlanner = new RoutePlanner(['Your-CIDR-Range/16'], ['exclude-ip'], 1) // ipBlocks, excludedIps, failedRetry, -1 = Default Value, 0 = Infinity
async function getRelated (url) {
    try {
    const results = await Client.get(url, routePlanner)
    console.log(`Scraped ${results.length} related videos`)
    console.log(results)
    } catch (e) {
        console.log('An Error appeared')
        console.log(e.stack)
    }
}

Releases

No releases published

Packages

No packages published

Languages

  • HTML 99.7%
  • Other 0.3%