New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

google-play-scraper

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-play-scraper - npm Package Compare versions

Comparing version 0.0.5 to 0.1.0

lib/developer.js

13

lib/app.js

@@ -5,4 +5,6 @@ var Promise = require('promise');

var h = require('./helpers');
function App(id, lang) {
function app(id, lang) {
var lang = lang || 'en';

@@ -13,3 +15,3 @@

request(url)
.then(cheerio.load, requestError)
.then(cheerio.load, h.requestError)
.then(parseFields)

@@ -25,7 +27,2 @@ .then(function(app) {

function requestError() {
//TODO improve details
throw Error('Error retrieving application');
}
function parseFields($) {

@@ -68,2 +65,2 @@ var installs = $('[itemprop="numDownloads"]').text().trim();

module.exports = App;
module.exports = app;

@@ -6,4 +6,7 @@ var c = require('./constants');

module.exports.App = require('./app');
module.exports.List = require('./list');
module.exports.app = require('./app');
module.exports.list = require('./list');
module.exports.search = require('./search');
module.exports.suggest = require('./suggest');
module.exports.developer = require('./developer');

@@ -7,4 +7,5 @@ var Promise = require('promise');

var c = require('./constants');
var h = require('./helpers');
function List(opts) {
function list(opts) {

@@ -18,4 +19,4 @@ return new Promise(function (resolve, reject) {

request(url)
.then(cheerio.load, requestError)
.then(parseList)
.then(cheerio.load, h.requestError)
.then(h.parseList)
.then(resolve)

@@ -47,2 +48,3 @@ .catch(reject);

opts.lang = opts.lang || 'en';
opts.country = opts.country || 'us';
}

@@ -58,3 +60,3 @@

url += '/collection/' + opts.collection;
url += '?hl=' + opts.lang + '&start=' + opts.start + '&num=' + opts.num;
url += '?hl=' + opts.lang + '&gl=' + opts.country + '&start=' + opts.start + '&num=' + opts.num;

@@ -66,39 +68,2 @@ console.log(url);

function requestError() {
//TODO improve details
throw Error('Error retrieving list');
}
function parseList($) {
var apps = [];
$('.card').each(function(i, v){
apps.push(parseApp($, v));
});
return apps;
}
function parseApp($, app) {
var price = $(app).find('.display-price').first().text();
var free = price === 'Free';
if (free) {
price = '0';
}
var scoreText = $(app).find(".tiny-star").attr("aria-label");
var score = parseFloat(scoreText.match(/[\d.]+/)[0]);
return {
url: 'https://play.google.com' + $(app).find('a').attr('href'),
appId: $(app).attr('data-docid'),
title: $(app).find('.title').attr('title'),
developer: $(app).find('.subtitle').text(),
icon: $(app).find('.cover-image').attr('data-cover-large'),
score: score,
price: price,
free: free
};
}
module.exports = List;
module.exports = list;
{
"name": "google-play-scraper",
"version": "0.0.5",
"version": "0.1.0",
"description": "scrapes app data from google play store",

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

# google-play-scraper
Scrapes basic application data from the Google Play store.
## Installation
```
npm install google-play-scraper
```
## Usage
### Get an App detail
### app(appId, lang)
The App function is used to retrieve the full detail of an application.
Retrieves the full detail of an application. Parameters:
* `appId`: the Google Play id of the application (the `?id=` parameter on the url).
* `lang` (optional, defaults to `'en'`): the two letter language code in which to fetch the app page.
Example:
```javascript
var gplay = require('google-play-scrapper');
gplay.App('com.dxco.pandavszombies')
gplay.app('com.dxco.pandavszombies')
.then(function(app){

@@ -20,3 +30,3 @@ console.log('Retrieved application: ' + app.title);

```
The returned app object has the following format:
Results:

@@ -43,11 +53,18 @@ ```javascript

The App function takes the app id (the `?id=` parameter on the application url) and an optional parameter to specify the language in which to fetch the app page (for example 'es' for Spanish. Defaults to 'en').
### list(opts)
Retrieve a list of applications from one of the collections at Google Play. Options:
### Get an App list
The List function allows to retrieve a list of applications from one of the collections at Google Play:
* `collection` (optional, defaults to `collection.TOP_FREE`): the Google Play collection that will be retrieved. Available options can bee found [here](https://github.com/facundoolano/google-play-scraper/blob/dev/lib/constants.js#L49).
* `category` (optional, deafaults to no category): the app category to filter by. Available options can bee found [here](https://github.com/facundoolano/google-play-scraper/blob/dev/lib/constants.js#L2).
* `num` (optional, defaults to 60, max is 120): the amount of apps to retrieve.
* `start` (optional, defaults to 0, max is 500): the starting index of the retrieved list.
* `lang` (optional, defaults to `'en'`): the two letter language code used to retrieve the applications.
* `country` (optional, defaults to `'us'`): the two letter country code used to retrieve the applications.
Example:
```javascript
var gplay = require('google-play-scrapper');
gplay.List({
gplay.list({
category: gplay.category.GAME_ACTION,

@@ -64,3 +81,3 @@ collection: gplay.collection.TOP_FREE,

```
The result will look like:
Results:

@@ -86,7 +103,92 @@ ```javascript

The List function takes a configuration object which accepts the following parameters:
* `collection`: the Google Play collection that will be retrieved. Defaults to `collection.TOP_FREE`, available options can bee found [here](https://github.com/facundoolano/google-play-scraper/blob/dev/lib/constants.js#L49).
* `category`: the app category to filter by. Defaults to no category, available options can bee found [here](https://github.com/facundoolano/google-play-scraper/blob/dev/lib/constants.js#L2).
* `num`: the amount of apps to retrieve. Max allowed is 120, defaults to 60.
* `start`: the starting index of the retrieved list. Max allowed is 500, defaults to 0.
* `lang`: the two letter language code used to retrieve the applications. Defaults to `'en'`.
### search(opts)
Retrieves a list of apps that results of searching by the given term. Options:
* `term`: the term to search by.
* `num` (optional, defaults to 20, max is 250): the amount of apps to retrieve.
* `lang` (optional, defaults to `'en'`): the two letter language code used to retrieve the applications.
* `country` (optional, defaults to `'us'`): the two letter country code used to retrieve the applications.
Example:
```javascript
var gplay = require('google-play-scrapper');
gplay.search({
term: "panda",
num: 2
}).then(console.log, console.log);
```
Results:
```javascript
[ { url: 'https://play.google.com/store/apps/details?id=com.snailgameusa.tp',
appId: 'com.snailgameusa.tp',
title: 'Taichi Panda',
developer: 'Snail Games USA',
icon: 'https://lh3.googleusercontent.com/g8RMjpRk9yetsui4g5lxnioAFwtgoKUJDBnb2knJMrOaLOtHrwU1qYkb-PadbL0Zmg=w340',
score: 4.1,
price: '0',
free: true },
{ url: 'https://play.google.com/store/apps/details?id=com.sgn.pandapop.gp',
appId: 'com.sgn.pandapop.gp',
title: 'Panda Pop',
developer: 'SGN',
icon: 'https://lh5.ggpht.com/uAAUBzEHtD_-mTxomL2wFxb5VSdtNllk9M4wjVdTGMD8pH79RtWGYQYrrtfVTjq7PV7M=w340',
score: 4.2,
price: '0',
free: true } ]
```
### developer(devId, lang)
Returns the list of applications by the given developer name. Parameters:
* `devId`: the name of the developer.
* `lang` (optional, defaults to `'en'`): the two letter language code in which to fetch the app list.
Example:
```javascript
var gplay = require('google-play-scrapper');
gplay.developer("DxCo Games").then(console.log);
```
Results:
```javascript
[ { url: 'https://play.google.com/store/apps/details?id=com.dxco.pandavszombies',
appId: 'com.dxco.pandavszombies',
title: 'Panda vs Zombie: Elvis rage',
developer: 'DxCo Games',
icon: 'https://lh6.ggpht.com/5mI27oolnooL__S3ns9qAf_6TsFNExMtUAwTKz6prWCxEmVkmZZZwe3lI-ZLbMawEJh3=w340',
score: 4.7,
price: '0',
free: true },
{ url: 'https://play.google.com/store/apps/details?id=com.dxco',
appId: 'com.dxco',
title: 'Pirate Run: Queer Buccaneer',
developer: 'DxCo Games',
icon: 'https://lh3.ggpht.com/biLJnt699Gce5U8nLb91T9w2sQ2deUL3Ealn5MI3fbyohIFjccd7E6d9fPzoVwbyc_Q=w340',
score: 4.6,
price: '0',
free: true } ]
```
### suggest(term)
Given a string returns up to five suggestion to complete a search query term.
Example:
```javascript
var gplay = require('google-play-scrapper');
gplay.suggest("panda").then(console.log);
```
Results:
```javascript
[ 'panda pop',
'panda',
'panda games',
'panda run',
'panda pop for free' ]
```
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc