google-play-scraper
Advanced tools
Comparing version 9.0.0 to 9.0.1
@@ -64,10 +64,2 @@ // constants | ||
GROSSING = 'GROSSING', | ||
TOP_FREE_GAMES = 'TOP_FREE_GAMES', | ||
TOP_PAID_GAMES = 'TOP_PAID_GAMES', | ||
TOP_GROSSING_GAMES = 'TOP_GROSSING_GAMES', | ||
TRENDING = 'TRENDING', | ||
NEW_FREE = 'NEW_FREE', | ||
NEW_PAID = 'NEW_PAID', | ||
NEW_FREE_GAMES = 'NEW_FREE_GAMES', | ||
NEW_PAID_GAMES = 'NEW_PAID_GAMES' | ||
} | ||
@@ -74,0 +66,0 @@ |
@@ -93,2 +93,7 @@ 'use strict'; | ||
const hasAboutTheseResults = R.is(String, R.path(SECTIONS_MAPPING.aboutResultsTitle, html)); | ||
if (hasAboutTheseResults) { | ||
R.path(mappings.sections, html).shift(); | ||
} | ||
const sections = R.path(mappings.sections, html); | ||
@@ -100,3 +105,3 @@ let moreResultsSection; | ||
} else { | ||
moreResultsSection = sections.filter(section => R.path(SECTIONS_MAPPING.title, section) === MORE_RESULTS)[0]; | ||
moreResultsSection = sections.filter(section => isMoreSection(section))[0]; | ||
if (moreResultsSection) { | ||
@@ -123,2 +128,7 @@ mainApp = scriptData.extractor(mainAppMapping)(R.path(mappings.app, html)); | ||
function isMoreSection (section) { | ||
const sectionTitle = R.path(SECTIONS_MAPPING.title, section); | ||
return R.is(String, sectionTitle) && !R.isEmpty(sectionTitle); | ||
} | ||
const INITIAL_MAPPINGS = { | ||
@@ -133,7 +143,6 @@ app: ['ds:4', 0, 1, 0, 23], | ||
apps: [22, 0], | ||
noResults: [25, 0, 0, 0, 1] | ||
noResults: [25, 0, 0, 0, 1], | ||
aboutResultsTitle: ['ds:4', 0, 1, 0, 31, 0] | ||
}; | ||
const MORE_RESULTS = 'More results'; | ||
function getPriceGoogleValue (value) { | ||
@@ -140,0 +149,0 @@ switch (value.toLowerCase()) { |
{ | ||
"name": "google-play-scraper", | ||
"version": "9.0.0", | ||
"version": "9.0.1", | ||
"description": "scrapes app data from google play store", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -35,2 +35,6 @@ 'use strict'; | ||
module.exports = { assertValidUrl, assertValidApp }; | ||
function assertIdsInArray (apps, ...ids) { | ||
assert.isTrue(ids.every((id) => apps.some((app) => app.appId === id))); | ||
} | ||
module.exports = { assertValidUrl, assertValidApp, assertIdsInArray }; |
'use strict'; | ||
const gplay = require('../index'); | ||
const assertValidApp = require('./common').assertValidApp; | ||
const { assertValidApp, assertIdsInArray } = require('./common'); | ||
const assert = require('chai').assert; | ||
@@ -46,2 +46,57 @@ | ||
})); | ||
describe('country and language specific', () => { | ||
describe('without more results section', () => { | ||
it('should fetch a valid application list for eu country', () => { | ||
return gplay.search({ term: 'Panda vs Zombies', country: 'GH' }) | ||
.then((apps) => apps.map(assertValidApp)); | ||
}); | ||
it('should fetch a valid application list for non eu country', () => { | ||
return gplay.search({ term: 'Facebook', country: 'GE' }) | ||
.then((apps) => apps.map(assertValidApp)); | ||
}); | ||
it('should fetch a valid application list for eu country with specific language', () => { | ||
return gplay.search({ term: 'Panda vs Zombies', country: 'BE', lang: 'it' }) | ||
.then((apps) => apps.map(assertValidApp)); | ||
}); | ||
}); | ||
}); | ||
describe('more results mapping', () => { | ||
it('schould return few netflix apps', () => { | ||
return gplay.search({ term: 'netflix' }) | ||
.then((apps) => { | ||
assert.equal(apps[0].appId, 'com.netflix.mediaclient'); | ||
assertIdsInArray(apps, 'com.netflix.ninja', 'com.netflix.NGP.StrangerThings'); | ||
}); | ||
}); | ||
it('should return few netflix apps from german store with german language', () => { | ||
return gplay.search({ term: 'netflix', lang: 'de', country: 'DE' }) | ||
.then((apps) => { | ||
assert.equal(apps[0].appId, 'com.netflix.mediaclient'); | ||
assertIdsInArray(apps, 'com.netflix.ninja', 'com.netflix.NGP.StrangerThings'); | ||
}); | ||
}); | ||
it('should reutrn few google mail apps', () => { | ||
return gplay.search({ term: 'gmail' }) | ||
.then((apps) => { | ||
assert.equal(apps[0].appId, 'com.google.android.gm'); | ||
assertIdsInArray(apps, 'com.google.android.gm.lite', 'com.google.android.apps.docs'); | ||
}); | ||
}); | ||
it('should return apps for search with a category as query', () => { | ||
return gplay.search({ term: 'games' }) | ||
.then((apps) => assertIdsInArray(apps, 'com.kiloo.subwaysurf')); | ||
}); | ||
it('should throw if no result returned', () => { | ||
return gplay.search({ term: 'asdasdyxcnmjysalsaflaslf' }) | ||
.catch((error) => assert.isNotEmpty(error.message)); | ||
}); | ||
}); | ||
}); |
130978
2655