google-play/node_modules/google-play-scraper/lib/utils/scriptData.js
/*
 * Extract the javascript objects returned by the AF_initDataCallback functions
 * in the script tags of the app detail HTML.
 */
Extract the javascript objects returned by the AF_initDataCallback functions
in the script tags of the app detail HTML.
Extract the javascript objects returned by the AF_initDataCallback functions in the script tags of the app detail HTML .
function parse (response) {
  const scriptRegex = />AF_initDataCallback[\s\S]*?<\/script/g;
  const keyRegex = /(ds:.*?)'/;
  const valueRegex = /return ([\s\S]*?)}}\);<\//;
  const matches = response.match(scriptRegex);
  if (!matches) {
    return {};
  }
  return matches.reduce((accum, data) => {
    const keyMatch = data.match(keyRegex);
    const valueMatch = data.match(valueRegex);
    if (keyMatch && valueMatch) {
      const key = keyMatch[1];
      const value = JSON.parse(valueMatch[1]);
      return R.assoc(key, value, accum);
    }
    return accum;
  }, {});
}
function parse ( response ) { const scriptRegex = / >AF_initDataCallback[\s\S]*?<\/script / g ; const keyRegex = / (ds:.*?)' / ; const valueRegex = / return ([\s\S]*?)}}\);<\/ / ; const matches = response . match ( scriptRegex ) ; if ( ! matches ) { return { } ; } return matches . reduce ( ( accum , data ) => { const keyMatch = data . match ( keyRegex ) ; const valueMatch = data . match ( valueRegex ) ; if ( keyMatch && valueMatch ) { const key = keyMatch [ 1 ] ; const value = JSON . parse ( valueMatch [ 1 ] ) ; return R . assoc ( key , value , accum ) ; } return accum ; } , { } ) ; }
Extract the javascript objects returned by the AF_initDataCallback functions
 in the script tags of the app detail HTML.
Extract the javascript objects returned by the AF_initDataCallback functions in the script tags of the app detail HTML .