Skip to content

Commit ad97452

Browse files
committed
parseApplication(): try obtaining missing values via protobuf again
1 parent ba7d836 commit ad97452

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

google-play.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,18 @@ public function parseApplication($packageName, $lang='en_US', $loc='US') {
203203
$values["votes"] = $this->getRegVal('/<div class="g1rdde">(?<content>[^>]+) reviews<\/div>/i');
204204
$values["price"] = $this->getRegVal('/<meta itemprop="price" content="(?<content>[^"]+)">/i');
205205

206-
$limit = 3;
207-
while ( empty($values["summary"]) && $limit > 0 ) { // sometimes protobuf is missing, but present again on subsequent call -- no longer showing up on retries either with design change in 2022-05?
208-
$proto = json_decode($this->getRegVal('/data:(?<content>\[\[\[.+?). sideChannel: .*?\);<\/script/ims'));
209-
if ( empty($proto[0][10]) ) {
206+
$limit = 5; $proto = '';
207+
while ( empty($proto) && $limit > 0 ) { // sometimes protobuf is missing, but present again on subsequent call
208+
$proto = json_decode($this->getRegVal("/key: 'ds:4'. hash: '7'. data:(?<content>\[\[\[.+?). sideChannel: .*?\);<\/script/ims")); // ds:8 hash:22 would have reviews
209+
if ( empty($proto) || empty($proto[1]) ) {
210+
$this->getApplicationPage($packageName, $lang, $loc);
210211
--$limit;
211-
$this->getApplicationPage($packageName, $lang, $loc);
212212
} else {
213-
$values["summary"] = $proto[0][10][1][1];
213+
if ( empty($values["featureGraphic"]) ) $values["featureGraphic"] = $proto[1][2][96][0][3][2];
214+
if ( empty($values["video"]) && !empty($proto[1][2][100]) ) $values["video"] = $proto[1][2][100][0][0][3][2];
215+
if ( empty($values["summary"]) && !empty($proto[1][2][73]) ) $values["summary"] = $proto[1][2][73][0][1]; // 1, 2, 73, 0, 1
216+
// screenshots: 1,2,78,0,0-n; 1=format,2=[wid,hei],3.2=url
217+
// more details see: https://github.com/JoMingyu/google-play-scraper/blob/2caddd098b63736318a7725ff105907f397b9a48/google_play_scraper/constants/element.py
214218
break;
215219
}
216220
}

0 commit comments

Comments
 (0)