Skip to content

Repository files navigation

page-scrapper

CI npm

Scrape all links and images from a web page.

Installation

Requires Node.js 20 or later. Ships with TypeScript types.

npm install page-scrapper

Usage

import pageScrapper from 'page-scrapper';

const result = await pageScrapper('https://jsonplaceholder.typicode.com/');

console.log(result);

Output:

{
    links: [
        'https://github.com/typicode/mistcss',
        'https://github.com/sponsors/typicode',
        'https://blog.typicode.com',
        'https://my-json-server.typicode.com',
        'https://github.com/typicode/json-server',
        'https://github.com/typicode/lowdb',
        'https://github.com/users/typicode/sponsorship',
        'https://github.com/typicode'
    ],
    images: [
        'https://github.com/user-attachments/assets/adfee31f-a8b6-4684-9a9b-af4f03ac5b75'
    ]
}

Options

Pass an options object as the second argument:

const result = await pageScrapper(url, { absoluteOnly: false });
Option Required Default Description
absoluteOnly No true Only scrape the absolute links. When set to false it will include the relative paths too.

Related

meta-fetcher: Simple metadata scraper for Node.js.

License

MIT 2021-2026 © Rocktim Saikia

About

Scrape all links and images from a web page

Topics

Resources

Stars

13 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages