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

imdb-watchlist-scraper

v2.0.4

Published

Scrape IMDb ratings list

Downloads

1,160

Readme

IMDb Watchlist Scraper

Overview

This library provides a WatchlistScraper class for scraping IMDb watchlist data, including rating IDs and usernames, using the IMDb user ID.


Class Initialization

Parameters

  • userId (string, required):
    IMDb user ID string, formatted like 'ur125655832'.

  • headless (boolean, optional):
    Default: true.
    Determines whether the browser runs in headless mode. Set to false for testing purposes.

  • timeoutInMs (number, optional):
    Default: 3 minutes (180000 ms).
    The script timeout duration. If a timeout occurs, the watchlistGrabIds() function will console.error() and return null.

  • userAgent (string, optional):
    Default:
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36".
    Refer to Playwright documentation for user agent formatting details. This is used in Playwright's browser.newContext()


Usage

Main Function: watchlistGrabIds()

Description

watchlistGrabIds() opens a playwright browser, navigates to the watchlist and scrapes all of the IDs in that watchlist.

Return Value

On success, the function returns an object:

{
  idArr: string[], // Array of rating IDs
  username: string | null // IMDb username, or null if unavailable
}

Error cases

The function throws an error explicitly in the following cases:

  1. The target watchlist is privated
  2. Parsing time exceeds the time set in timeoutInMs
  3. Parsing completes but the returned idArr is empty

Example

Scraping All Rating IDs and Username by userId

const scraper = new WatchlistScraper({ userId: "ur125655832" });

try {
	const scrapingResults = await scraper.watchlistGrabIds();

	// username can be null
	const username = scrapingResults.username;
	if (!!username) {
		console.log(username);
	}

	// this is never null and always has at least 1 element
	const idArr = scrapingResults.idArr;
	console.log(idArr);
} catch (error) {
	// handle error
}