Skip to content

Commit fdb859b

Browse files
committed
add search for similar apps
1 parent 5018f60 commit fdb859b

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Tiny script to crawl information of a specific application in the Google play/st
66

77
- parse
88
- parseSearch
9+
- parseSimilar
910
- parseCategory
1011
- parseCategories
1112
- parseApplication
@@ -21,8 +22,7 @@ $google = new GooglePlay();
2122
$app=$google->parseApplication("com.bezapps.flowdiademo");
2223
print_r($app);
2324

24-
25-
$app=$google->parseApplication("com.bezapps.flowdiademo");
25+
$app=$google->parseSimilar("com.bezapps.flowdiademo");
2626
print_r($app);
2727

2828
$apps=$google->parseSearch("telegram");

google-play.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,18 @@ public function parseApplication($packageName, $lang='en_US', $loc='US') {
147147
/** Parse page specified by URL for playstore links and extract package names
148148
* @method public parse
149149
* @param optional string link link to parse; if empty or not specified, defaults to 'https://play.google.com/apps'
150+
* @param optional bool is_url whether the link passed is an url to fetch-and-parse (true, default) or a string just to parse (false)
150151
* @return array array of package names
151152
*/
152-
public function parse($link=null) {
153-
if($link == "" || $link == null) {
154-
$link = "https://play.google.com/apps";
153+
public function parse($link=null, $is_url=true) {
154+
if ( $is_url ) {
155+
if ($link == "" || $link == null) {
156+
$link = "https://play.google.com/apps";
157+
}
158+
$input = file_get_contents($link);
159+
} else {
160+
$input = $link;
155161
}
156-
$input = file_get_contents($link);
157162
preg_match_all('/href="\/store\/apps\/details\?id=(?<ids>[^\"]+)"/i', $input, $ids);
158163
if ( isset($ids["ids"]) ) {
159164
$ids = $ids["ids"];
@@ -249,6 +254,20 @@ public function parseCategories() {
249254
return array_unique($cats[1]);
250255
}
251256

257+
/** Obtain list of similar apps
258+
* @method parseSimilar
259+
* @param string packageName package name of the app to find similars for, e.g. 'com.example.app'
260+
* @return array array of package names
261+
*/
262+
public function parseSimilar($packageName) {
263+
if ( ! $this->getApplicationPage($packageName) )
264+
return ['success'=>0,'message'=>$this->lastError];
265+
$input = $this->getRegVal('!<h2 class="sv0AUd bs3Xnd">Similar</h2></a>(?<content>.+?)(<c-wiz jsrenderer="rx5H8d"|</aside>)!ims');
266+
if ( empty($input) )
267+
return ['success'=>0,'message'=>'no data found'];
268+
return $this->parse($input, false);
269+
}
270+
252271
/** Search for apps by a given string
253272
* @method public parseSearch
254273
* @param string query string to search for

0 commit comments

Comments
 (0)