How to Get the Best Prices for Your Products with Scraping and Price Intelligence

  • Associated Searches
  • Product Pricing
  • Product Reviews
https://www.etsy.com/search?q=t-shirt+fallout
https://www.etsy.com/search?q=t-shirt+fallout&page=2&ref=pagination
https://www.etsy.com/search?q=t-shirt+fallout&page=3&ref=pagination
const cheerio = require(‘cheerio’);
const axios = require(‘axios’);
const api_key = ‘********************************’;
const urls = [
‘https://www.etsy.com/search?q=t-shirt+fallout',
‘https://www.etsy.com/search?q=t-shirt+fallout&page=2&ref=pagination',
‘https://www.etsy.com/search?q=t-shirt+fallout&page=3&ref=pagination'
];
const api_url = `https://api.webscrapingapi.com/v1?api_key=${api_key}&session=20210505&url=`;
(async () => {
let total_price = 0;
let products_count = 0;
for(let i = 0; i < urls.length; i++) {
let response;
try {
response = await axios.get(api_url + encodeURIComponent(urls[i]));
} catch (error) {
console.log(error);
process.exit();
}
const $ = cheerio.load(response.data);
const $products = $(‘ul.tab-reorder-container.wt-grid.wt-grid — block > li’);
// Parse the products list
}
console.log(`Average price: ${parseFloat(total_price/products_count).toFixed(2)}`);
process.exit();
})();
$products.each((index, product) => {
const $product = $(product);
const $currencyValue = $product.find(‘.v2-listing-card__info .n-listing-card__price .currency-value’);
const price = parseFloat($currencyValue.eq(0).text());
if(price) {
total_price += price;
products_count++;
}
})
node index.js

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store