README
vinbudin-scraper
A scraper for www.vinbudin.is
Why?
Vínbúðin does not provide an open API. This package can be used to analyse their product data or create something else from it.
How?
This package extracts data from every product page on www.vinbudin.is and returns a JSON Object.
CLI
The quickest way to try this package out is using the CLI:
npx vinbudin-scraper
This will allow you to select what you want to scrape. The scraped data will be saved as a products.json
file in the same folder that you ran the scraper.
Try selecting Cider and soda
as that should not take much more than 2 minutes to complete.
Usage
Install from npm and save to your package.json
:
npm install vinbudin-scraper --save
Examples
Basic
const vinbudin = require("vinbudin-scraper");
vinbudin.scrape().then((scrapedData) => {
// Handle the scraped data
console.log(scrapedData);
});
// You can also provide an options object to get specific data
vinbudin
.scrape({
beer: true,
redWine: true,
whiteWine: true,
roseWine: true,
sparklingWine: true,
dessertWine: true,
ciderAndSoda: true,
spirit: true,
})
.then((scrapedData) => {
// Handle the scraped data
console.log(scrapedData);
});
Saving results to a local file
const vinbudin = require("vinbudin-scraper");
const fs = require("fs");
async function vinbudinExample() {
const products = await vinbudin.scrape();
const scrapedData = {
products,
};
fs.writeFile("data.json", JSON.stringify(scrapedData), "utf8", (err) => {
if (err) {
return console.log(err);
}
console.log("Scrape complete, see './data.json'");
});
}
vinbudinExample();