New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

get-preview-image

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-preview-image

return first image of a web page

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

Get preview image

This tool will look inside a page and find the preview image.

Example

import { getFirstImageOfPage } from "get-preview-image/scrapeImage.js";

console.log(
  await getFirstImageOfPage(
    "http://blog.hasan.one/programming/web/2023-01-30-Display-temporary-message-using-react-hooks.html"
  )
); // logs image link

Dependencies

Depends on "node-html-parser" for parsing the page.

How it works

The tool first looks for an image inside the header tags of the page. This is where most websites keep links to preview images.

If the page has no image link in the header, the tool looks inside the body of the page for the first element with "img" tag and returns its link.

Developer

Hasan Aga

FAQs

Package last updated on 09 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts