opensea-scraper
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "opensea-scraper", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Scraping accurate floor prices from opensea, because the API returns inacurate floor prices.", | ||
@@ -5,0 +5,0 @@ "main": "src/OpenseaScraper.js", |
@@ -26,4 +26,11 @@ const axios = require("axios"); | ||
const cardsArray = Array.prototype.slice.call(cardsNodeList); // you cannot use .map on a nodeList, we need to transform it to an array | ||
const priceStr = cardsArray[0].querySelector(".Price--amount").textContent; | ||
return Number(priceStr.split(",").join(".")); | ||
const floorPrices = cardsArray.map(card => { | ||
try { | ||
const priceStr = card.querySelector(".Price--amount").textContent; | ||
return Number(priceStr.split(",").join(".")); | ||
} catch(err) { | ||
return undefined; | ||
} | ||
}).filter(val => val); // filter out invalid (undefined) values | ||
return Math.min(...floorPrices); // sometimes the order of elements is not accurate on Opensea, thats why we need to get the lowest value | ||
}); | ||
@@ -30,0 +37,0 @@ await browser.close(); |
5722
127