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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Commands:
Options:
--help, -h help [boolean]
--version Show version number [boolean]
--path, -p Location for saving the results [string] [default: "."]
--async, -a Number of async tasks [string] [default: "5"]
--keyword, -k Amazon search keyword ex. 'Xbox one' [string] [default: ""]
--number, -n Number of products to scrape. Maximum 100 products or 300
Expand Down Expand Up @@ -105,6 +106,7 @@ Examples:
amazon-buddy asin B01GW3H3U8
amazon-buddy categories
amazon-buddy countries
amazon-buddy --country "DE" asin B0039N480I --path ~/results --filetype all
```

#### Example 1
Expand Down
18 changes: 17 additions & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env node

const fs = require("fs"); // To allow saving outside of current directory

const AmazonScraper = require('../lib');

const startScraper = async (argv) => {
Expand Down Expand Up @@ -60,6 +62,12 @@ require('yargs')
alias: 'h',
describe: 'help',
},
path: {
alias: 'p',
default: '.',
type: 'string',
describe: 'Location for saving the results',
},
async: {
alias: 'a',
default: '5',
Expand All @@ -80,7 +88,7 @@ require('yargs')
},
filetype: {
default: 'csv',
choices: ['csv', 'json', 'all', ''],
choices: ['csv', 'json', 'all', '', 'html'],
describe: "Type of the output file where the data will be saved. 'all' - save data to the 'json' and 'csv' files",
},
sort: {
Expand Down Expand Up @@ -163,6 +171,14 @@ require('yargs')
}
}

// checking the path
if (argv.path){
const pathToDir = argv.path

// check if the path is valid to write
fs.accessSync(pathToDir, fs.constants.W_OK);
}

// Minimum allowed rating is 1
if (!argv['min-rating']) {
argv['min-rating'] = 1;
Expand Down
Loading