UNPKG

@stormking/emere

Version:

a nightmarejs replacement for scraping websites using electron.

37 lines (27 loc) 1.05 kB
# Emere # Small tool to retrieve HTML or PDF from a loaded webpage with electron. Works as a minimal replacement for nightmare.js since it hasn't been getting updates for years. ## Usage See src/main.test.ts for more examples. ```javascript import run from 'emere'; let bufferWithHtml = await run({ url: 'http://example.org', waitForSelector: 'h1' }); ``` ### Options API ```typescript type RunScript = { url: string, //webpage to call header?: Record<string, string|string[]>, //headers to send when loading body?: string, //request body to send method?: string, //HTTP method to use referrer?: string, //HTTP referrer to set waitAfterLoad?: number, //wait for ms before grabbing the page. still respects timeout waitForSelector?: string, //wait up to the timeout until this element appears on the page userAgent?: string, //user-agent to set timeout?: number, //timeout for the whole process. will kill electron process get?: 'html'|'pdf' //defaults to html when not set } ```