app-store-scraper
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -7,1 +7,2 @@ 'use strict'; | ||
module.exports.suggest = require('./lib/suggest'); | ||
module.exports.similar = require('./lib/similar'); |
@@ -43,6 +43,11 @@ 'use strict'; | ||
// TODO add an optional parse function | ||
function request (url) { | ||
return new Promise((resolve, reject) => superagent | ||
.get(url) | ||
.end(function (err, res) { | ||
function request (url, headers) { | ||
return new Promise(function (resolve, reject) { | ||
const req = superagent.get(url); | ||
headers = headers || {}; | ||
Object.keys(headers).map(function (k) { | ||
req.set(k, headers[k]); | ||
}); | ||
return req.end(function (err, res) { | ||
if (err || !res.ok) { | ||
@@ -53,3 +58,4 @@ reject(err); | ||
resolve(res.text); | ||
})); | ||
}); | ||
}); | ||
} | ||
@@ -56,0 +62,0 @@ |
{ | ||
"name": "app-store-scraper", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "scrape data from the itunes app store", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,2 +17,3 @@ # app-store-scraper | ||
- [suggest](#suggest): Given a string returns up to 50 suggestions to complete a search query term. | ||
- [similar](#similar): Returns the list of "customers also bought" apps shown in the app's detail page. | ||
@@ -143,2 +144,34 @@ ### app | ||
Example: | ||
```js | ||
var store = require('app-store-scraper'); | ||
store.search({ | ||
term: 'panda', | ||
num: 2, | ||
device: store.search.IOS | ||
}) | ||
.then(console.log) | ||
.catch(console.log); | ||
``` | ||
Results: | ||
```js | ||
[ | ||
{ id: 903990394, | ||
appId: 'com.pandarg.pxmobileapp', | ||
title: 'Panda Express Chinese Kitchen', | ||
(...) | ||
}, | ||
{ | ||
id: 700970012, | ||
appId: 'com.sgn.pandapop', | ||
title: 'Panda Pop', | ||
(...) | ||
} | ||
] | ||
``` | ||
### suggest | ||
@@ -171,1 +204,35 @@ | ||
``` | ||
### similar | ||
Returns the list of "customers also bought" apps shown in the app's detail page. Options: | ||
* `id`: the iTunes "trackId" of the app, for example `553834731` for Candy Crush Saga. Either this or the `appId` should be provided. | ||
* `appId`: the iTunes "bundleId" of the app, for example `com.midasplayer.apps.candycrushsaga` for Candy Crush Saga. Either this or the `id` should be provided. | ||
Example: | ||
```js | ||
var store = require('app-store-scraper'); | ||
store.similar({id: 553834731}).then(console.log).catch(console.log); | ||
``` | ||
Results: | ||
```js | ||
[ | ||
{ | ||
id: 632285588, | ||
appId: 'com.nerdyoctopus.dots', | ||
title: 'Dots: A Game About Connecting', | ||
(...) | ||
}, | ||
{ | ||
id: 727296976, | ||
appId: 'com.sgn.cookiejam', | ||
title: 'Cookie Jam', | ||
(...) | ||
} | ||
(...) | ||
] | ||
``` |
18056
12
306
236