How to Get All Google play store apps List using PHP Scraper ?
How to Get All Google play store apps List using PHP Scraper ?

Hi, friends Today we will learn How can you Get All Google play store apps list using PHP Scraper in simple steps. 

So Let's start.

Note - Please follow the steps carefully

Step -1 First of Create a folder in your root path then you have to add raulr/google-play-scraper as a require dependency in your composer.json file. Don't worry, we will create by this command in your folder where you will create PHP file for this.


Copy this and open your terminal or command line and run as shown in the image below.


  •      composer require raulr/google-play-scraper


How to Get All Google play store apps List using PHP Scraper ?




Step -2  After running this command go to your folder and create a file test.php. 


     include autoload.php file in your test.php file                include_once('vendor/autoload.php');


     use this library 

  use Raulr\GooglePlayScraper\Scraper;
  Make object of your Scrapper.
  $scraper = new Scraper(); 
  Then call getSearch funtion 
  $apps = $scraper->getSearch('Facebook', 'all', '4+');
 After pasting above code your file will look like this as shown in the image
 below.

Before printing the data you have to some change in your Scraper.php file.
just search parseSearchAppList function in your Scraper.php file. 
line number 432. 
protected function parseSearchAppList(Crawler $crawler)
{
return $crawler->filter('.WHE7ib')->each(function ($node) {
$app = array();
$app['url'] = $this->getAbsoluteUrl($node->filter('a.poRVub')->attr('href'));
$app['id'] = substr($app['url'], strpos($app['url'], '=') + 1);
$app['title'] = $node->filter('.b8cIId.ReQCgd.Q9MA7b')->attr('title');
$app['image'] = $this->getAbsoluteUrl($node->filter('img')->attr('data-src'));
$app['author'] = $node->filter('.b8cIId.ReQCgd.KoLSrc a div')->text();
$ratingNode = $node->filter('.pf5lIe [aria-label]');
if (!$ratingNode->count()) {
$rating = 0.0;
} elseif (preg_match('/\d+([.,]\d+)?/', $ratingNode->attr('aria-label'), $matches)) {
$rating = floatval(str_replace(',', '.', $matches[0]));
} else {
throw new \RuntimeException('Error parsing rating');
}
$app['rating'] = $rating;
$priceNode = $node->filter('.VfPpfd.ZdBevf.i5DZme span');
if (!$priceNode->count()) {
$price = null;
} elseif (!preg_match('/\d/', $priceNode->text())) {
$price = null;
} else {
$price = $priceNode->text();
}
$app['price'] = $price;

return $app;
});
}
I have some changed in the above function. Just copy the below code and paste it in your parseSearchAppList function.
return $crawler->filter('.ImZGtf')->each(function ($node) {
$app = array();
$app['url'] = $this->getAbsoluteUrl($node->filter('a.poRVub')->attr('href'));
$app['id'] = substr($app['url'], strpos($app['url'], '=') + 1);
$app['title'] = $node->filter('.b8cIId.ReQCgd.Q9MA7b a div')->attr('title');
$app['image'] = $this->getAbsoluteUrl($node->filter('img')->attr('data-src'));
$app['author'] = $node->filter('.b8cIId.ReQCgd.KoLSrc a div')->text();
$ratingNode = $node->filter('.pf5lIe [aria-label]');
if (!$ratingNode->count()) {
$rating = 0.0;
} elseif (preg_match('/\d+([.,]\d+)?/', $ratingNode->attr('aria-label'), $matches)) {
$rating = floatval(str_replace(',', '.', $matches[0]));
} else {
throw new \RuntimeException('Error parsing rating');
}
$app['rating'] = $rating;

if($node->filter('.LCATme')->count() > 0 ) {
$priceNode = $node->filter('.LCATme')->text();
}else{
$priceNode = null ;
}

$app['price'] = $priceNode;
return $app;
});
And finally just print the data using print_r funciton.
echo "<pre>";print_r($apps);
Note - It will give 50 results at once.
Output 
How to Get All Google play store apps List using PHP Scraper ?
Yeah! You have learned ЁЯШК
I hope you understood this and like this article. if you like it so, please give feedback in the comment section.

If any mistakes I made here, so please let me know and improve me.
If you have any query, feel free to ask me  ЁЯШК 

Post a Comment

Please do not enter any spam link in the comment section.

Previous Post Next Post