forked from joepie91/barcodebot
Calorielijst added as source
This commit is contained in:
parent
43281fd5b3
commit
818132e8f1
|
@ -37,6 +37,7 @@ let barcodeGetters = [
|
|||
getBarcode_foodBook,
|
||||
getBarcode_eanData,
|
||||
getBarcode_openFoodFacts,
|
||||
getBarcode_calorielijst,
|
||||
];
|
||||
|
||||
module.exports = function getBarcode(barcode) {
|
||||
|
@ -230,3 +231,27 @@ function getBarcode_bolCom(barcode) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getBarcode_calorielijst(barcode) {
|
||||
return Promise.try(() => {
|
||||
log(barcode, "Trying calorielijst.nl...");
|
||||
|
||||
return bhttp.get(`http://www.calorielijst.nl/?search=${encodeURIComponent(barcode)}`);
|
||||
}).then((response) => {
|
||||
if (response.statusCode === 200) {
|
||||
let $ = cheerio.load(response.body);
|
||||
|
||||
let a = $(".calorienamediv a").first();
|
||||
let productName = cleanValue(a.text());
|
||||
|
||||
if (productName.length > 0) {
|
||||
let image = a.data().id;
|
||||
return {
|
||||
name: productName,
|
||||
image: (image != "") ? `http://img.calorielijst.nl/product/${image}` : null,
|
||||
//~ price: "N/A",
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue