Skip to content

joegesualdo/youtube-video-scraper-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@joegesualdo/youtube-video-scraper-node Build Status

Get information from the html of a youtube video page.

Install

$ npm install --save @joegesualdo/youtube-video-scraper-node 

Usage

import YoutubeVideoScraper from "@joegesualdo/youtube-video-scraper-node"

let videoId = 'D_U6luQ6I90'
new YoutubeVideoScraper(videoId)
.then(scraper => {
  scraper.getMetaInformation()
  .then(meta => {
    console.log(meta)
  })
  .catch(err => {
    console.log(err)
  })
  scraper.getAuthorInfo()
  .then(author => {
    console.log(author)
  })
  scraper.getDescriptionExtras()
  .then(result => {
    console.log(result)
  })
  scraper.getViewCount()
  .then(viewCount=> {
    console.log(viewCount)
  })
})

API

YoutubeVideoScraper(videoId)

Constructor: Creates a scraper instance

Name Type Description
videoId String The ID of the youtube video

Returns: Promise, and passes the instance of YoutubeVideoScraper

import YoutubeVideoScraper from "@joegesualdo/youtube-video-scraper-node"

let videoId = 'D_U6luQ6I90'
new YoutubeVideoScraper(videoId)
.then(scraper => {
  scraper.getAuthorInfo()
  .then(meta => {
    console.log(meta)
  })
})

getMetaInformation()

Get the meta information of the youtube video

Returns: Object, that represent all the meta information.

import YoutubeVideoScraper from "@joegesualdo/youtube-video-scraper-node"

let videoId = 'D_U6luQ6I90'
new YoutubeVideoScraper(videoId)
.then(scraper => {
  scraper.getMetaInformation()
  .then(meta => {
    console.log(meta)
  })
  .catch(err => {
    console.log(err)
  })
})

getAuthorInfo()

Get information about the author of the video

Returns: Object, with the keys name and channelId

import YoutubeVideoScraper from "@joegesualdo/youtube-video-scraper-node"

let videoId = 'D_U6luQ6I90'
new YoutubeVideoScraper(videoId)
.then(scraper => {
  scraper.getAuthorInfo()
  .then(author=> {
    console.log(author)
  })
  .catch(err => {
    console.log(err)
  })
})

getDescriptionExtras()

Gets extra information

Returns: Object

import YoutubeVideoScraper from "@joegesualdo/youtube-video-scraper-node"

let videoId = 'D_U6luQ6I90'
new YoutubeVideoScraper(videoId)
.then(scraper => {
  scraper.getDescriptionExtras()
  .then(result => {
    console.log(result)
  })
  .catch(err => {
    console.log(err)
  })
})

getViewCount()

Get the number of views.

Returns: Number that represent number of view a video has

import YoutubeVideoScraper from "@joegesualdo/youtube-video-scraper-node"

let videoId = 'D_U6luQ6I90'
new YoutubeVideoScraper(videoId)
.then(scraper => {
  scraper.getViewCount()
  .then(meta => {
    console.log(meta)
  })
  .catch(err => {
    console.log(err)
  })
})

Test

$ npm test

Build

$ npm run build

Related

License

MIT © Joe Gesualdo

About

Get information from the html of a youtube video page.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published