npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

js-imdb-scraper

v0.1.2

Published

Simple IMDB scraper

Downloads

2

Readme

js-imdb-scraper

Scrapes TV Show data from the IMDB website.

Getting Started

To install, use:

npm i js-imdb-scraper

Then either import the entire module, or whichever methods you need:

const imdb = require("js-imdb-scraper");

// OR

const { getSearchResults, getSeasonRatings, getAllRatings, getNumSeasons } = require("js-imdb-scraper");

Usage

Get IMDB Search Results

The getSearchResults(showName) method uses the IMDB search page to list shows that mach the given input string. The input string should contain letters, numbers and spaces only. This is usually enough to find the right shows. This method will only show TV Shows, not movies.

const imdb = require("js-imdb-scraper");

const example = async () => {
  const searchResults = await imdb.getSearchResults("westworld");
  return searchResults;
}

This method gives us:

[
  {
    title: 'Westworld (2016)',
    id: 'tt0475784',
    img: 'https://m.media-amazon.com/images/M/MV5BMTRmYzNmOTctZjMwOS00ODZlLWJiZGQtNDg5NDY5NjE3MTczXkEyXkFqcGdeQXVyMDM2NDM2MQ@@._V1_UX32_CR0,0,32,44_AL_.jpg'
  },
  {
    title: 'Beyond Westworld (1980)',
    id: 'tt0080198',
    img: 'https://m.media-amazon.com/images/M/MV5BMTU4NTIyMjM3Ml5BMl5BanBnXkFtZTgwMDk0OTQ0MzE@._V1_UX32_CR0,0,32,44_AL_.jpg'
  }
]

Get a seasons ratings

Once we have the the show details, we can use the IMDB show ID to get a seasons ratings using getSeasonRating(showId, season). Here, we select the 2016 westworld show and find season 1 ratings:

const imdb = require("js-imdb-scraper");

const example = async () => {
  const searchResults = await imdb.getSearchResults("westworld");
  const selectedShowId = searchResults[0].id;
  const seasonOneRatings = await imdb.getSeasonRatings(selectedShowId, 1);
  return seasonOneRatings;
}

This gives us:

{
    season: 1,
    ratings: [
      { episode: 1, rating: '8.9' },
      { episode: 2, rating: '8.6' },
      { episode: 3, rating: '8.4' },
      { episode: 4, rating: '8.7' },
      { episode: 5, rating: '8.7' },
      { episode: 6, rating: '8.9' },
      { episode: 7, rating: '9.5' },
      { episode: 8, rating: '8.8' },
      { episode: 9, rating: '9.4' },
      { episode: 10, rating: '9.7' }
    ],
}

Get all seasons ratings

With the IMDB show ID we can receive all season ratings using getAllRatings(showId):

const imdb = require("js-imdb-scraper");

const example = async () => {
  const searchResults = await imdb.getSearchResults("westworld");
  const selectedShowId = searchResults[0].id;
  const allSeasonRatings = await imdb.getAllRatings(selectedShowId);
  return allSeasonRatings;
}

This gives us:

{
  '1': [
    { episode: 1, rating: '8.9' },
    { episode: 2, rating: '8.6' },
    { episode: 3, rating: '8.4' },
    { episode: 4, rating: '8.7' },
    { episode: 5, rating: '8.7' },
    { episode: 6, rating: '8.9' },
    { episode: 7, rating: '9.5' },
    { episode: 8, rating: '8.8' },
    { episode: 9, rating: '9.4' },
    { episode: 10, rating: '9.7' }
  ],
  '2': [
    { episode: 1, rating: '8.2' },
    { episode: 2, rating: '8.1' },
    { episode: 3, rating: '8.0' },
    { episode: 4, rating: '9.0' },
    { episode: 5, rating: '7.9' },
    { episode: 6, rating: '8.2' },
    { episode: 7, rating: '8.6' },
    { episode: 8, rating: '9.2' },
    { episode: 9, rating: '8.8' },
    { episode: 10, rating: '8.8' }
  ],
  '3': [
    { episode: 1, rating: '8.5' },
    { episode: 2, rating: '8.4' },
    { episode: 3, rating: '8.4' },
    { episode: 4, rating: '9.0' },
    { episode: 5, rating: '8.2' },
    { episode: 6, rating: '8.5' },
    { episode: 7, rating: '8.1' },
    { episode: 8, rating: '7.4' }
  ]
}

Get number of seasons

With the IMDB ID we can find the number of show seasons by using getNumSeasons(showId):

const imdb = require("js-imdb-scraper");

const example = async () => {
  const searchResults = await imdb.getSearchResults("westworld");
  const selectedShowId = searchResults[0].id;
  const numSeasons = await imdb.getNumSeasons(selectedShowId);
  return numSeasons;
}

This gives us:

1

License

This project is licensed under the MIT license - see the LICENSE file for details.