diff --git a/README.md b/README.md index 0793506..fe2c83e 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,7 @@ recipeScraper("some.recipe.url").then(recipe => { - https://www.thespruceeats.com/ - https://whatsgabycooking.com/ - https://www.woolworths.com.au/ +- https://www.yellowblissroad.com/ - https://www.yummly.com/ - https://www.jamieoliver.com/ diff --git a/helpers/ScraperFactory.js b/helpers/ScraperFactory.js index b1d3719..49f586c 100644 --- a/helpers/ScraperFactory.js +++ b/helpers/ScraperFactory.js @@ -45,6 +45,7 @@ const domains = { thespruceeats: require("../scrapers/TheSpruceEatsScraper"), whatsgabycooking: require("../scrapers/WhatsGabyCookingScraper"), woolworths: require("../scrapers/WoolworthsScraper"), + yellowblissroad: require("../scrapers/YellowBlissRoadScraper"), yummly: require("../scrapers/YummlyScraper"), jamieoliver: require("../scrapers/JamieOliverScraper") }; diff --git a/scrapers/YellowBlissRoadScraper.js b/scrapers/YellowBlissRoadScraper.js new file mode 100644 index 0000000..f193734 --- /dev/null +++ b/scrapers/YellowBlissRoadScraper.js @@ -0,0 +1,52 @@ +"use strict"; + +const BaseScraper = require("../helpers/BaseScraper"); + +class YellowBlissRoadScraper extends BaseScraper { + constructor(url) { + super(url, "yellowblissroad.com/"); + } + + scrape($) { + this.defaultSetImage($); + this.defaultSetDescription($); + this.recipe.name = $(".wprm-recipe-name").text(); + const { ingredients, instructions, time } = this.recipe; + + $(".wprm-recipe-ingredient").each((i, el) => { + let amount = $(el) + .find(".wprm-recipe-ingredient-amount") + .text(); + let unit = $(el) + .find(".wprm-recipe-ingredient-unit") + .text(); + let name = $(el) + .find(".wprm-recipe-ingredient-name") + .text(); + let ingredient = `${amount} ${unit} ${name}` + .replace(/\s\s+/g, " ") + .trim(); + ingredients.push(ingredient); + }); + + $(".wprm-recipe-instruction").each((i, el) => { + instructions.push(this.textTrim($(el))); + }); + + time.prep = + `${$(".wprm-recipe-prep_time").text()} ${$( + ".wprm-recipe-prep_time-unit" + ).text()}` || ""; + time.cook = + `${$(".wprm-recipe-cook_time").text()} ${$( + ".wprm-recipe-cook_time-unit" + ).text()}` || ""; + time.total = + `${$(".wprm-recipe-total_time").text()} ${$( + ".wprm-recipe-total_time-unit" + ).text()}` || ""; + this.recipe.servings = $(".wprm-recipe-servings").text() || ""; + } +} + +module.exports = YellowBlissRoadScraper; diff --git a/test/constants/yellowblissroadConstants.js b/test/constants/yellowblissroadConstants.js new file mode 100644 index 0000000..0600ec3 --- /dev/null +++ b/test/constants/yellowblissroadConstants.js @@ -0,0 +1,40 @@ +module.exports = { + testUrl: + "https://www.yellowblissroad.com/cranberry-brie-bites/", + invalidUrl: "https://www.yellowblissroad.com/notarealurl", + invalidDomainUrl: "www.invalid.com", + nonRecipeUrl: "https://www.yellowblissroad.com/about/", + expectedRecipe: { + name: 'Cranberry Brie Bites', + description: 'Cranberry Brie Bites are a sweet and tangy bite-sized appetizer. Creamy brie cheese in a flaky crescent roll cup topped with cranberry sauce.', + ingredients: [ + '8 ounce tube crescent roll dough', + 'flour for rolling out the dough', + '6 ounces Brie cheese', + '¼ cup orange marmalade', + '¼ cup whole cranberry sauce', + '¼ cup chopped pistachios, pecans or walnuts', + 'fresh rosemary or candied orange pieces for garnish' + ], + instructions: [ + 'Preheat oven to 375 degrees F and grease a 24-count mini-muffin pan with nonstick cooking spray.', + 'Cut the brie into small, about 1-inch (or a little less) squares and set aside in the refrigerator until ready to use.', + 'In a small bowl, mix together orange marmalade and cranberry sauce. Set aside.', + 'Lightly flour a flat surface, like a large wooden cutting board, and roll out the tub of crescent dough. Stretch slightly to form an evenly sided rectangle and pinch seams together. Cut into 24 even sized squares.', + 'Place the squares into the prepared muffin cups. Top with brie cheese square and a teaspoon (or a little less) of the orange-cranberry mixture. Top with a few of the chopped nuts and a small sprig of rosemary.', + 'Slide the muffin pan into the oven and bake for about 10-13 minutes, or until golden brown and dough is cooked through.', + 'Let cool 5-10 minutes and serve warm.' + ], + tags: [], + time: { + prep: '15 minutes mins', + cook: '13 minutes mins', + active: '', + inactive: '', + ready: '', + total: '28 minutes mins' + }, + servings: '8', + image: 'https://www.yellowblissroad.com/wp-content/uploads/2019/11/Cranberry-Brie-Bites-9.jpg' + } +}; diff --git a/test/yellowblisskitchen.test.js b/test/yellowblisskitchen.test.js new file mode 100644 index 0000000..18178ac --- /dev/null +++ b/test/yellowblisskitchen.test.js @@ -0,0 +1,5 @@ +"use strict"; +const commonRecipeTest = require("./helpers/commonRecipeTest"); +const constants = require("./constants/yellowblissroadConstants"); + +commonRecipeTest("yellowblissroad", constants, "yellowblissroad.com/");