@@ -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