deno.land / x / google_play_scraper@v10.0.0 / lib / datasafety.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import * as R from 'ramda';import request from './utils/request.js';import scriptData from './utils/scriptData.js';import { BASE_URL } from './constants.js';
function dataSafety (opts) { return new Promise(function (resolve, reject) { if (!opts && !opts.appId) { throw Error('appId missing'); }
opts.lang = opts.lang || 'en';
processDataSafety(opts) .then(resolve) .catch(reject); });}
function processDataSafety (opts) { const PLAYSTORE_URL = `${BASE_URL}/store/apps/datasafety`;
const searchParams = new URLSearchParams({ id: opts.appId, hl: opts.lang }); const reqUrl = `${PLAYSTORE_URL}?${searchParams}`;
const options = Object.assign({ url: reqUrl, followRedirect: true }, opts.requestOptions);
return request(options, opts.throttle) .then(scriptData.parse) .then(scriptData.extractor(MAPPINGS));}
const MAPPINGS = { sharedData: { path: ['ds:3', 1, 2, 137, 4, 0, 0], fun: mapDataEntries }, collectedData: { path: ['ds:3', 1, 2, 137, 4, 1, 0], fun: mapDataEntries }, securityPractices: { path: ['ds:3', 1, 2, 137, 9, 2], fun: mapSecurityPractices }, privacyPolicyUrl: ['ds:3', 1, 2, 99, 0, 5, 2]};
function mapSecurityPractices (practices) { if (!practices) { return []; }
return practices.map((practice) => ({ practice: R.path([1], practice), description: R.path([2, 1], practice) }));}
function mapDataEntries (dataEntries) { if (!dataEntries) { return []; }
return dataEntries.flatMap(data => { const type = R.path([0, 1], data); const details = R.path([4], data);
return details.map(detail => ({ data: R.path([0], detail), optional: R.path([1], detail), purpose: R.path([2], detail), type })); });}
export default dataSafety;
google_play_scraper

Version Info

Tagged at
9 months ago