这表明该应用程序图标是在Div中与“ Doc-Banner-Icon”类中举行的 - 我在其他任何地方都找不到此类,因此我认为这是唯一的班级Div。然后,在我的php代码中,我使用
<?php
include('simple_html_dom.php');
$html = file_get_html("https://play.google.com/store/apps/details?id=com.smithyproductions.swissarmycarrot"); //put your app id here
$bannerImage = $html->find('.doc-banner-icon'); //the class we found before
$img = $bannerImage[0]->find('img'); //find the img tag inside the div
$imgUrl = $img[0]->src; //get its src url
$arr = array(); //in my own example I filled this array with other things like the title an screenshots
$arr['imgUrl'] = $imgUrl;
echo json_encode($arr); //output it in an easy to read format
?>
在类似的东西上享受 {'imgurl','Https://lh6.ggpht.com/1wmu4e3lnbjz5yxlhxsprjajpw3uyz8lxk3qkdkd1ekoxwochu0w9qyglpm5afrkyevzzi = w124} 关于这种方法要牢记的一件事:Google可以随时更改所有内容的展示方式和布局,因此准备在发生这种情况时更新您的应用程序:)
I通过roarster
修改了代码,以与Play商店的新网页一起工作,我简化了它:
<?php
include('simple_html_dom.php');
$play_link = $_GET['playlink']; //Play store link
$html = file_get_html($play_link); //put your app id here
$bannerImage = $html->find('div.cover-container'); //the class we found before
$img = $bannerImage[0]->find('img'); //find the img tag inside the div
$imgUrl = $img[0]->src; //get its src url
$arr = array(); //in my own example I filled this array with other things like the title an screenshots
$arr['imgUrl'] = $imgUrl;
echo json_encode($arr); //output it in an easy to read format
?>
现在您加载:
yourwebpage.com/script.php?playlink=https://play.google.com/store/apps/details?id=com.igg.android.im
PS:在我的代码中,一旦设法获得图标URL,就会在数据库中缓存它,因此我不必在Google Play商店中再次查找它
try{
$lookupData = @file_get_contents('https://play.google.com/store/apps/details?id=com.google.android.gm&hl=en');
// Not valid any more
$pregString = '/<meta itemprop="image" content="(.*?)"\/>/';
//June 2019
$pregString = '/<img src="(.*?)" srcset=".*" class=".*" aria-hidden="true" alt="Cover art" itemprop="image">/';
preg_match($pregString, $lookupData, $output);
} catch (\Throwable $e) {
$error = $e->getMessage();
if (strpos($error, '404 Not Found') === false) {
//unknown error
}else{
//Package not found, use default icon or something
}
}
if(isset($output[1])){
//Store $output[1];
}else{
//icon not found, use default icon or something
}
这里是PHP 7的工作和简单解决方案。最新的2025