deno.land / x / google_play_scraper@v10.0.0 / lib / categories.js
123456789101112131415161718192021222324252627282930313233343536373839import request from './utils/request.js';import * as cheerio from 'cheerio';import { BASE_URL } from './constants.js';
const PLAYSTORE_URL = `${BASE_URL}/store/apps`;const CATEGORY_URL_PREFIX = '/store/apps/category/';
function categories (opts) { opts = Object.assign({}, opts);
return new Promise(function (resolve, reject) { const options = Object.assign( { url: PLAYSTORE_URL }, opts.requestOptions );
request(options, opts.throttle) .then(cheerio.load) .then(extractCategories) .then(resolve) .catch(reject); });}
function extractCategories ($) { const categoryIds = $('ul li a') .toArray() .map((el) => $(el).attr('href')) .filter((url) => url.startsWith(CATEGORY_URL_PREFIX) && !url.includes('?age=')) .map((url) => url.substr(CATEGORY_URL_PREFIX.length)); categoryIds.push('APPLICATION');
return categoryIds;}
export default categories;
Version Info