Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ Options:
blocking from the amazon side [boolean] [default: false]
--user-agent Set custom user-agent [string] [default: ""]
--timeout, -t Timeout between requests. Timeout is set in mls: 1000 mls = 1

--seller Allows to set the seller-id (A....) to limit searches to
products offered by this seller and show prices of this seller
[string] [default: ""]

Examples:
amazon-buddy products -k 'Xbox one'
Expand Down
5 changes: 5 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ require('yargs')
type: 'number',
describe: 'Timeout between requests. Timeout is set in mls: 1000 mls = 1 second',
},
seller: {
default: '',
type: 'string',
describe: 'Allows to set the seller-id (A....) to limit searches to products offered by this seller and show prices of this seller',
},
})
.check((argv) => {
if (['products', 'reviews', 'asin', 'categories', 'countries'].indexOf(argv['_'][0]) === -1) {
Expand Down
5 changes: 4 additions & 1 deletion lib/Amazon.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class AmazonScraper {
asyncTasks,
reviewFilter,
referer,
seller,
}) {
this.asyncTasks = asyncTasks;
this.asyncPage = 1;
Expand Down Expand Up @@ -71,6 +72,7 @@ class AmazonScraper {
this.initTime = Date.now();
this.ua = ua || 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36';
this.reviewFilter = reviewFilter;
this.seller = seller;
}

/**
Expand Down Expand Up @@ -247,7 +249,7 @@ class AmazonScraper {
console.log(`Result was saved to: ${this.fileName}`);
}
return {
...(this.scrapeType === 'products' ? { totalProducts: this.totalProducts, category: this.productSearchCategory } : {}),
...(this.scrapeType === 'products' ? { totalProducts: this.totalProducts, category: this.productSearchCategory, seller: this.seller } : {}),
...(this.scrapeType === 'reviews' ? { ...this.reviewMetadata } : {}),
result: this.collector,
};
Expand Down Expand Up @@ -386,6 +388,7 @@ class AmazonScraper {
? {
k: this.keyword,
...(this.productSearchCategory ? { i: this.productSearchCategory } : {}),
...(this.seller ? { me: this.seller, m: this.seller } : {}),
...(page > 1 ? { page, ref: `sr_pg_${page}` } : {}),
}
: {}),
Expand Down
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const INIT_OPTIONS = {
filterByStar: '',
formatType: 'all_formats',
},
seller: '',
};

exports.products = async (options) => {
Expand Down