deno.land / x / google_play_scraper@v10.0.0 / lib / categories.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import 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;
google_play_scraper

Version Info

Tagged at
9 months ago