Manual Reference Source Test
import PopApiScraper from 'pop-api-scraper/src/PopApiScraper.js'
public class | source

PopApiScraper

Class for Initiating the scraping process.

Test:

Static Member Summary

Static Private Members
private static

A map of the installed plugins.

Static Method Summary

Static Public Methods
public static

Register middleware for the PopApi framework.

Constructor Summary

Public Constructor
public

constructor(PopApi: PopApi, options: Object)

Create a new BaseScraper object.

Member Summary

Public Members
public

The context to execute the providers in.

public

The path of the status file.

public

The path of the updated file.

Method Summary

Public Methods
public

Get the status object.

public

Get the updated object.

public

async scrape(concurrency: number): Promise<Array<Object>, Error>

Initiate the scraping.

public

Updates the status.json file.

public

Updates the updated.json file.

Static Private Members

private static _installedPlugins: Map source

A map of the installed plugins.

Static Public Methods

public static use(Plugin: Function, args: Object): Promise<PopApiScraper> source

Register middleware for the PopApi framework.

Params:

NameTypeAttributeDescription
Plugin Function
  • nullable: false

The plugin to use.

args Object
  • nullable: false

The arguments passed down to the constructor of the plugin.

Return:

Promise<PopApiScraper>

The PopApi instance with the installed plugins.

Test:

Public Constructors

public constructor(PopApi: PopApi, options: Object) source

Create a new BaseScraper object. The base modules for popcorn-api

Params:

NameTypeAttributeDescription
PopApi PopApi
  • nullable: false

The PopApiScraper instance.

options Object
  • nullable: false

The options for the BaseScraper middleware.

options.statusPath string
  • nullable: false

= - The path of the status file.

options.updatedPath string
  • nullable: false

The path of the updated file.

Test:

Public Members

public context: Context source

The context to execute the providers in.

public statusPath: string source

The path of the status file. Default is ./tmp/status.json.

public updatedPath: string source

The path of the updated file. Default is ./tmp/updated.json.

Public Methods

public getStatus(): Promise<string, Error> source

Get the status object.

Return:

Promise<string, Error>

The status of the scraping process.

Test:

public getUpdated(): Promise<number, Error> source

Get the updated object.

Return:

Promise<number, Error>

The status of the scraping process.

Test:

public async scrape(concurrency: number): Promise<Array<Object>, Error> source

Initiate the scraping.

Params:

NameTypeAttributeDescription
concurrency number
  • optional
  • default: 1
  • nullable: false

How many providers to scrape concurrently.

Return:

Promise<Array<Object>, Error>

The array of the scraped content.

Test:

public setStatus(status: string): Promise<undefined, Error> source

Updates the status.json file.

Params:

NameTypeAttributeDescription
status string
  • nullable: false

The status which will be set to in the status.json file.

Return:

Promise<undefined, Error>

'ok' if saved, or the error is there is one.

Test:

public setUpdated(updated: number): Promise<undefined, Error> source

Updates the updated.json file.

Params:

NameTypeAttributeDescription
updated number
  • nullable: false

The epoch time when the API last started scraping.

Return:

Promise<undefined, Error>

'ok' if saved, or the error is there is one.

Test: