puppeteer-evals
is a Node.js package that provides a set of utility functions for working with Puppeteer, making it easier to extract information from web pages.
You can install puppeteer-evals
using npm:
npm install puppeteer-evals
First, import and initialize the package:
const evals = require('puppeteer-evals');
evals();
// Or, you can use it in one line:
// require('puppeteer-evals')();
After initialization, all functions can be called directly without referencing 'evals' again.
Example usage (assuming you've set up Puppeteer and have a 'page' object):
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
// Now you can use the evals functions:
const inputValues = await getInputs(page);
const buttonTexts = await getButtons(page);
const usernameValue = await getAttribute(page, 'input[name="username"]', 'value');
await browser.close();
Here's a list of available methods:
getInputs(page)
: Get all input valuesgetTextareas(page)
: Get all textarea valuesgetSelects(page)
: Get all select valuesgetCheckboxes(page)
: Get all checkbox valuesgetRadios(page)
: Get all radio valuesgetButtons(page)
: Get all button textsgetLinks(page)
: Get all link hrefsgetInteractables(page)
: Get all interactable elementsgetPageText(page)
: Get the page textgetPageHtml(page)
: Get the page HTMLgetPageAttributes(page, selector, attribute)
: Get attributes of elements matching a selectorgetPageRefs(page)
: Get all page references (links and sources)findElement(page, selector)
: Find an elementfindAllElements(page, selector)
: Find all elements matching a selectorgetInnerText(page, selector)
: Get the inner text of an elementgetInnerHTML(page, selector)
: Get the inner HTML of an elementgetAttribute(page, selector, attribute)
: Get an attribute of an elementFor more details on each method, you can use the help()
function after initialization.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.