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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@dimfu/recipe-scraper

v0.3.0

Published

Extract recipe data from the web effortlessly

Downloads

733

Readme

@dimfu/recipe-scraper

Scrap food recipe data from various websites that support JSON+LD and Microdata schema, no guessing involved.

Install

npm install --save @dimfu/recipe-scraper

Usage

Basic

Pass a url as first parameter will attempt to extract the recipe content from that website.

import getRecipeData from '@dimfu/recipe-scraper'

const url = 'https://example/recipes/creamy-courgette-potato-bake'

getRecipeData(url).then((recipe) => {
  console.log(recipe)
})

or with async/await

import getRecipeData from '@dimfu/recipe-scraper'

async function run() {
  const url = 'https://example/recipes/creamy-courgette-potato-bake'
  const recipe = await getRecipeData(url)
  console.log(recipe)
}

HTML String

If you already have HTML string and dont want to make an http request, you can specify it in option object:

Note This can be work only if there is JSON-LD or Microdata schema tags were present.

import getRecipeData from '@dimfu/recipe-scraper'

const html = `
    <script type="application/ld+json">
        {
            "@context": "http://schema.org",
            "@type": "Recipe",
            "name": "Classic Marinara Sauce",
            "recipeIngredient": [
                "1 28-ounce can whole tomatoes",
                "1/4 cup olive oil",
                "7 garlic peeled and slivered",
                "Small dried whole chile",
                "1 teaspoon kosher salt",
                "1 large fresh basil sprig"
            ]
        }
     </script>
`

const recipe = await getRecipeData({ html })

import getRecipeData from '@dimfu/recipe-scraper'

const html = `
    <div itemscope itemtype="https://schema.org/Recipe">
        <h1 itemprop="name">Simple Marinara Sauce</h1>
        <div>
            <span itemprop="recipeIngredient">2 cans stewed tomatoes</span>
            <span itemprop="recipeIngredient">1 teaspoon dried oregano</span>
            <span itemprop="recipeIngredient">1 teaspoon salt</span>
        </div>
    </div>
`

const recipe = await getRecipeData({ html })

It returns back the information related to the given URL

{
  "url": "https://example/recipes/creamy-courgette-potato-bake",
  "name": "Creamy courgette & potato bake",
  "image": "https://example/stryve/9ae78bc2-ad5e-449c-8626-8c9faa37054c_creamy-courgette-potato-bake.png?auto=compress,format",
  "cookTime": "45 minutes",
  "prepTime": "25 minutes",
  "totalTime": "70 minutes",
  "recipeYield": 4,
  "recipeIngredients": [
    "1000g Potato",
    "2 Courgette",
    "2 Brown onion",
    "3tsp Olive oil",
    "120g Cashew nuts",
    "200ml Vegetable stock",
    "200ml Almond milk",
    "6 Garlic cloves",
    "18tsp Nutritional yeast",
    "2tsp Sea salt",
    "2tsp Smoked paprika"
  ],
  "recipeInstructions": [
    "Add cashew nuts to a bowl with enough hot water to cover",
    "Peel and thinly slice the potatoes and courgettes",
    "Thinly slice the onion and add to a pan with olive oil – fry for ~5 mins mixing often until lightly brown",
    "Pre-heat the oven on 180°C (355°F)",
    "Drain the water from cashew nuts and place in blender with vegetable stock, almond milk, garlic, nutritional yeast and salt – blend until smooth",
    "To your oven dish add a layer potato, followed by a layer of courgette, followed by the onion",
    "Next sprinkle half of the smoked paprika on top",
    "Continue adding another layer of potato, followed by another layer of courgette and pour ⅔ of the creamy sauce on top",
    "Finish off with one more layer of potatoes, the remaining sauce and the other half of the smoked paprika – place in the oven for 45 mins"
  ]
}

When a field can't be retrieved, the value will be undefined.

There are no guarantees about the shape of this data, because it varies with different media and scraping methods. Handle it carefully.

Configuration

You can change the behaviour by passing an options object:

import getRecipeData from '@dimfu/recipe-scraper'

const options = {
  url: 'https://example/recipes/creamy-courgette-potato-bake', // URL of web page
  maxRedirects: 0, // Maximum number of redirects to follow (default: 5)
  timeout: 1000, // Request timeout in milliseconds (default: 10000ms)
}

getRecipeData(options).then((recipe) => {
  console.log(recipe)
})

You can specify the URL by either passing it as the first parameter, or by setting it in the options object.

Command line usage

Using without installation

npx @dimfu/recipe-scraper https://example/recipes/creamy-courgette-potato-bake 

Note: Use this method only if you plan to use for one time, installing globally (see-below) is recommended for multiple time usages.

Installation

npm install @dimfu/recipe-scraper -g

Note for Linux & MacOS users: DO NOT use sudo to install global packages! The correct way is to tell npm where to install its global packages: npm config set prefix ~/.local. Make sure ~/.local/bin is added to PATH.

Usage after installation

@dimfu/recipe-scraper https://example/recipes/creamy-courgette-potato-bake

License

Distributed under the MIT License. See LICENSE for more information.