craigslist-search
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -13,9 +13,14 @@ var QueryCraigslist = module.exports = function(options, callback) { | ||
return; | ||
var isSites = options.city == 'www' | ||
if (!callback) | ||
callback = print | ||
if (!isSites) { | ||
if (options.citiesOnly) { | ||
callback(listings) | ||
return; | ||
} | ||
var all = options.allCities | ||
if (!all) { | ||
callback(listings) | ||
return; | ||
} | ||
@@ -22,0 +27,0 @@ // play with listings here... |
31
main.js
@@ -5,15 +5,27 @@ // USAGE node main [city/www(for all cities)] [category] [start record] [hasPic] | ||
var city = process.argv[2] | ||
if (!city) | ||
var argv = require('minimist')(process.argv.slice(2)) | ||
var citiesOnly = argv.citiesOnly | ||
if (citiesOnly) { | ||
qc({allCities: true, citiesOnly: true}) | ||
return | ||
} | ||
var all = argv.all | ||
var city = argv.city | ||
if (!city && !all) | ||
throw new Error('No city') | ||
var category = process.argv[3] | ||
var category = argv.category | ||
if (!category) | ||
throw new Error('No category') | ||
var offset = argv.offset | ||
var hasPic = argv.hasPic | ||
var query = argv.query | ||
var offset = process.argv[4] | ||
var hasPic = process.argv[5] | ||
var options = {category: category}; | ||
if (all) | ||
options.allCities = true | ||
if (city) | ||
options.city = city | ||
var options = {city: city, category: category} | ||
if (city == 'www') | ||
options.isSites = true | ||
if (offset) | ||
@@ -23,3 +35,4 @@ options.s = offset | ||
options.hasPic = 1 | ||
if (query) | ||
options.query = query | ||
qc(options) |
{ | ||
"name": "craigslist-search", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "Has 2 applications. 1. Can list craigslist listings in particular city in particular category. 2. Can list all the listings in all craigslist cities for one particular category", | ||
@@ -9,3 +9,5 @@ "main": "index.js", | ||
}, | ||
"devDependencies": {}, | ||
"devDependencies": { | ||
"minimist": "~1.1.0" | ||
}, | ||
"scripts": { | ||
@@ -12,0 +14,0 @@ "test": "echo \"Error: no test specified\" && exit 1" |
@@ -19,3 +19,3 @@ # Craigslist Search | ||
```bash | ||
node main.js newyork tia // gets first 100 ticket listings | ||
node main.js --city=newyork --category=tia // gets first 100 ticket listings | ||
``` | ||
@@ -25,3 +25,3 @@ get next 100 ticket listings | ||
```bash | ||
node main.js newyork tia 100 | ||
node main --city=newyork --category=tia --offset=100 | ||
``` | ||
@@ -31,5 +31,15 @@ to get tickets with images | ||
```bash | ||
node main.js newyork tia 0 true | ||
node main --city=newyork --category=tia --hasPic=true | ||
``` | ||
and with a query | ||
```bash | ||
node main --city=newyork --category=tia --hasPic=true --query=concert | ||
``` | ||
Get the list of all craigslist cities | ||
```bash | ||
node main --citiesOnly=true | ||
``` | ||
### Options | ||
@@ -41,3 +51,4 @@ ```javascript | ||
hasPic: 1, | ||
offset: 100 /* next 100 records */ | ||
offset: 100, /* next 100 records */ | ||
query: 'concert' | ||
} | ||
@@ -44,0 +55,0 @@ ``` |
5286
62
67
1