Socket
Socket
Sign inDemoInstall

amazon-buddy

Package Overview
Dependencies
116
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.4 to 2.2.5

81

lib/Amazon.js

@@ -955,2 +955,7 @@ // @ts-nocheck

const book_in_series = this.extractBookInSeries($);
if (book_in_series.length) {
output.book_in_series = book_in_series;
}
output.other_sellers = this.extractOtherSellers($);

@@ -1356,4 +1361,80 @@

}
/**
* Extract book series (if available)
* @param {*} $
*/
extractBookInSeries($) {
const series = [];
const booksInTheSeries = $(
'div.a-carousel-controls:nth-child(3) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > ol:nth-child(1)',
)[0];
if (booksInTheSeries && booksInTheSeries.children) {
booksInTheSeries.children.forEach((item, index) => {
try {
index += 1;
const reviews = {
total_reviews: 0,
rating: 0,
};
const price = {
symbol: this.geo.symbol,
currency: this.geo.currency,
current_price: 0,
};
const serie = $(
`div.a-carousel-controls:nth-child(3) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > ol:nth-child(1) > li:nth-child(${index}) > div:nth-child(1) > a:nth-child(1) > div:nth-child(1) > span:nth-child(1)`,
).text();
const image = $(
`div.a-carousel-controls:nth-child(3) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > ol:nth-child(1) > li:nth-child(${index}) > div:nth-child(1) > a:nth-child(1) > div:nth-child(1) > img:nth-child(2)`,
)[0].attribs.src;
const url = $(
`div.a-carousel-controls:nth-child(3) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > ol:nth-child(1) > li:nth-child(${index}) > div:nth-child(1) > a:nth-child(1)`,
)[0].attribs.href;
const title = $(
`div.a-carousel-controls:nth-child(3) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > ol:nth-child(1) > li:nth-child(${index}) > div:nth-child(1) > a:nth-child(2) > span:nth-child(1)`,
).text();
const total_reviews = $(
`div.a-carousel-controls:nth-child(3) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > ol:nth-child(1) > li:nth-child(${index}) > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > span:nth-child(1) > a:nth-child(1) > span:nth-child(2)`,
).text();
const rating = $(
`div.a-carousel-controls:nth-child(3) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > ol:nth-child(1) > li:nth-child(${index}) > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > span:nth-child(1) > a:nth-child(1) > i:nth-child(1) > span:nth-child(1)`,
)[0]
? $(
$(
`div.a-carousel-controls:nth-child(3) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > ol:nth-child(1) > li:nth-child(${index}) > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > span:nth-child(1) > a:nth-child(1) > i:nth-child(1) > span:nth-child(1)`,
)[0],
)
.text()
.split(/\s/g)[0]
: 0;
reviews.total_reviews = parseInt(total_reviews.replace(/[^\d]/g, ''), 10);
reviews.rating = rating;
const current_price = $(
`div.a-carousel-controls:nth-child(3) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > ol:nth-child(1) > li:nth-child(${index}) > div:nth-child(1) > div:nth-child(5)`,
).text();
price.current_price = this.geo.price_format(current_price);
series.push({
serie,
title,
images: [image],
url: `${this.mainHost}${url}`,
reviews,
price,
});
} catch {
// continue regardless of error
}
});
}
return series;
}
}
module.exports = AmazonScraper;

2

package.json
{
"name": "amazon-buddy",
"version": "2.2.4",
"version": "2.2.5",
"description": "Amazon Scraper. You can scrape products from amazon search result and you can also scrape reviews from a specific product",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc