2013-02-17 18 views
4

我开发,显示的应用程序列表中的应用程序,我想从谷歌Play商店应用程序的图标来显示它在列表中,那么如果有任何的方式来做到这一点,请告诉我。如何获得应用程序图标从谷歌播放动态

+0

尝试[Android的市场API(http://code.google.com/ p/Android的市场API /)。 – yorkw 2013-02-17 10:49:40

回答

3

我不得不最近解决这个问题,我自己在更新我的投资组合的网站,所以我甚至有一些代码为你:)我所做的是在PHP,但我不知道你想使用的东西。首先,我使用视图 - >开发技术>开发工具(在Chrome)检查页面的源代码写有我的应用程序。然后用,我可以遍历DOM寻找的东西我可以用它来识别应用程序图标。我发现这一点: screenshot

这是什么显示的是,应用程序图标举行一个div内与类“中的doc-旗帜图标” - 我无法找到这个类在其他地方,所以我想当然地认为它是唯一的那个班级。然后在我的PHP代码,我用simpledomparser加载网址,找到图标,吐出它的URL,就像这样:

<?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/1WMU4E3lnbjz5yxLHxsPrJAJPw3uYZ8LXk3QkD1EKOxwOcHu0W9QyGlpM5AfrKYEVzzi=w124'}

关于这种方法只需要记住一件事:Google可以随时更改所有内容的展示方式,以便在发生这种情况时更新您的应用:)

+0

它给出错误信息致命错误:在/home/quicksai/public_html/google/simple_html_dom.php调用未定义功能mb_detect_encoding() – 2014-05-16 04:49:01

+0

好像现在他们已经改变了结构,以''div.cover容器img.cover- image''。好主意,尽管完全不可靠。 – camelCaseCoder 2016-04-05 07:54:20

1

我修改了代码roarster以获得工作与Play商店的新网页和implified它:

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

,你得到的结果;)

相关问题