npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grabity

v1.0.5

Published

Get preview data from a link. Just grab it.

Downloads

1,138

Readme

Travis npm npm

grabity

Get preview data from a link. Just grab it! 🎣

Grabity looks through Open Graph and Twitter Cards markup to get Information about a link. Its functions will return as much data as they can from the markup. If no og or twitter tags are found, it will default to the content of the tag and meta description, and if either the title tag or meta description is missing, the returned property will be empty.

Getting Started:

npm install grabity

Usage:

It's really quite simple:

let grabity = require("grabity");

(async () => {
  let it = await grabity.grabIt("https://github.com/e-oj/grabity");

  console.log(it);
})();

Should produce:

{
  title: 'e-oj/grabity',
  description: 'grabity - Get preview data from a link. Just grab it! 🎣',
  image: 'https://avatars0.githubusercontent.com/u/9700116?s=400&v=4',
  favicon: 'https://assets-cdn.github.com/favicon.ico'
}

API

grabity.grabIt(url): Gets a title, description, image, and favicon from a url

url (required): url to be used

returns: object containing title, description, image, and favicon if found

Gets the og or twitter title, description and image from a url, as well as the favicon, and returns them in an object. If og and twitter tags exist for a property, the og tag is given preference. The twitter tag is selected if an og tag does not exist for a property. If there is no tag (og or twitter) for a property, that property is not included in the returned object.

let grabity = require("grabity");

(async () => {
 let it = await grabity.grabIt("https://www.flickr.com");

 console.log(it);
})();

result:

{
  title: 'Flickr, a Yahoo company',
  description: 'Flickr is almost certainly the best online photo management and sharing application in the world. Show off your favorite photos and videos to the world, securely and privately show content to your friends and family, or blog the photos and videos you take with a cameraphone.',
  image: 'https://farm4.staticflickr.com/3914/15118079089_489aa62638_b.jpg',
  favicon: 'https://s.yimg.com/pw/favicon.ico'
}

grabity.grab(url): Gets all og + twitter tags and their values, as well as the favicon,

url (required): url to be used

returns: object containing all found og + twitter tags and values, and favicon

Gets all existing og and twitter tags, as well as the favicon, from the markup and returns them in an object.

let grabity = require("grabity");

(async () => {
  let tags = await grabity.grab("https://www.flickr.com");

  console.log(tags);
})();

result:

{
  'og:site_name': 'Flickr',
  'og:updated_time': '2017-11-19T21:29:36.577Z',
  'og:title': 'Flickr, a Yahoo company',
  'og:type': 'website',
  'og:description': 'Flickr is almost certainly the best online photo management and sharing application in the world. Show off your favorite photos and videos to the world, securely and privately show content to your friends and family, or blog the photos and videos you take with a cameraphone.',
  'og:image': 'https://farm4.staticflickr.com/3914/15118079089_489aa62638_b.jpg',
  'twitter:card': 'summary_large_image',
  'twitter:creator': '@flickr',
  'twitter:title': 'Flickr, a Yahoo company',
  'twitter:description': 'Flickr is almost certainly the best online photo management and sharing application in the world. Show off your favorite photos and videos to the world, securely and privately show content to your friends and family, or blog the photos and videos you take with a cameraphone.',
  'twitter:image:src': 'https://farm4.staticflickr.com/3914/15118079089_489aa62638_b.jpg',
  favicon: 'https://s.yimg.com/pw/favicon.ico'
}

Test

To test this module, cd to the project directory and run:

npm run-script test-server

then in a seperate terminal:

npm test

Note: The test server runs on port 9973 by default. You can change the port number in test_setup/config.js