facundoolano / google-play-scraper

Node.js scraper to get data from Google Play
MIT License
2.32k stars 629 forks source link

similar API returns a wrong list #607

Open winhows5 opened 1 year ago

winhows5 commented 1 year ago

Description:

The similar API returns a wrong list for some apps. This list tends to be the developer apps.

Please see the testcase below. Both of them return a same app list.

Example code:

// Put code to reproduce the issue here
gplay.similar({appId: "com.codeway.wonder"}).then(console.log);
gplay.developer({devId: "Codeway Dijital"}).then(console.log);
winhows5 commented 1 year ago

This bug is caused when there's a column called "More by this developer" before "Similar apps", in which case the similar app item index is shifted.

Hence I temporarily fixed it by adding these code to lib/similar.js:75:

  // Temp fix for wrong similar apps =========================
  let similarAppsCluster = clusters.filter(cluster => {
    return R.path(CLUSTER_MAPPING.title, cluster) === SIMILAR_APPS;    // note: I don't concern the game category
  });

  if (similarAppsCluster.length === 0) {
    throw Error('Similar apps not found');
  }
  const clusterUrl = getParsedCluster(similarAppsCluster[0]);
  // End of fix=========================