我正在尝试获取我上传到Google Play的应用程序的下载量。
我正在寻找一个API (或类似的东西),检索我的下载数量与用户的身份验证。我不想要第三方应用程序(如AppAnnie)。
如果它能在PHP上运行那就太好了,我发现有一个库,我认为它是我能找到的从Google应用程序获取数据的最接近的API。
Google APIs Client Library for PHP
但我找不到任何提到Google Play应用程序的地方。
有没有什么方法可以下载到具有认证密钥的特定应用程序?
提前感谢!
发布于 2017-03-07 17:38:27
这是关于元数据api的。你可以看看下面的内容。
https://developers.google.com/android-publisher/api-ref/reviews
发布于 2017-03-05 17:10:22
使用google-play-scraper库获取应用信息,如下所示:
示例
$app = $scraper->getApp('com.mojang.minecraftpe');结果
array (
'id' => 'com.mojang.minecraftpe',
'url' => 'https://play.google.com/store/apps/details?id=com.mojang.minecraftpe',
'image' => 'https://lh3.googleusercontent.com/30koN0eGl-LHqvUZrCj9HT4qVPQdvN508p2wuhaWUnqKeCp6nrs9QW8v6IVGvGNauA=w300',
'title' => 'Minecraft: Pocket Edition',
'author' => 'Mojang',
'author_link' => 'https://play.google.com/store/apps/developer?id=Mojang',
'categories' => array (
'Arcade',
'Creativity',
),
'price' => '$6.99',
'screenshots' => array (
'https://lh3.googleusercontent.com/VkLE0e0EDuRID6jdTE97cC8BomcDReJtZOem9Jlb14jw9O7ytAGvE-2pLqvoSJ7w3IdK=h310',
'https://lh3.googleusercontent.com/28b1vxJQe916wOaSVB4CmcnDujk8M2SNaCwqtQ4cUS0wYKYn9kCYeqxX0uyI2X-nQv0=h310',
// [...]
),
'description' => 'Our latest free update includes the Nether and all its inhabitants[...]',
'description_html' => 'Our latest free update includes the Nether and all its inhabitants[...]',
'rating' => 4.4726405143737793,
'votes' => 1136962,
'last_updated' => 'October 22, 2015',
'size' => 'Varies with device',
'downloads' => '10,000,000 - 50,000,000',
'version' => 'Varies with device',
'supported_os' => 'Varies with device',
'content_rating' => 'Everyone 10+',
'whatsnew' => 'Build, explore and survive on the go with Minecraft: Pocket Edition[...]',
'video_link' => 'https://www.youtube.com/embed/D2Z9oKTzzrM?ps=play&vq=large&rel=0&autohide=1&showinfo=0&autoplay=1',
'video_image' => 'https://i.ytimg.com/vi/D2Z9oKTzzrM/hqdefault.jpg',
)编辑:轻松获取下载量,如下所示:
echo $app['downloads']; // Outputs: '10,000,000 - 50,000,000'或者,如果你想要左边的值:
$matches = null;
$returnValue = preg_match('/.*(?= -)/', '10,000,000 - 50,000,000', $matches);
echo $matches[0]; // Outputs: '10,000,000'或者,如果您想要正确的值:
$matches = null;
$returnValue = preg_match('/(?<=- ).*/', '10,000,000 - 50,000,000', $matches);
echo $matches[0]; // Outputs: '50,000,000'然后使用以下命令轻松地将其转换为整数:
$count = null;
$returnValue = (int)preg_replace('/,/', '', $matches[0], -1, $count);
echo $returnValue; // Outputs: 10000000 or 50000000发布于 2017-03-07 05:44:55
你需要Scrape它。一般来说,当然在这种特殊情况下,当网站(这里: Google Play)没有提供API来使您(客户)的所需数据可供他访问时,Web抓取是收集您所需信息的最佳方法之一。
几乎你在网页上看到的每一条信息都可以被抓取。如今,随着网络抓取器的巨大改进,你不仅能够从目标网站抓取数据,而且“像用户一样抓取它”,“通过表单向网站发布信息”,“以用户身份登录”等已经成为任何网络抓取器的例行公事。
有非常强大的抓取器,像Scrapy(可能是最有名的,用Python语言编写的),几乎适用于每种语言。PHP中最好的网页抓取器是由FriendsOfPHP的传奇@fabpot编写的Goutte。
在数据提取POV中,Goutte同时支持"CSS Selectors“和XPath (因为它使用Symfony's DOM Crawler作为爬行引擎)。这样你就可以按照你想要的方式爬行文档,提取网页任何隐藏角落中的每一条信息!
你可以用Goutte抓取很远的东西,但这只是一个很小的例子,可以在一眨眼的功夫从一个普通的App页面中抓取“安装数量”:
use Goutte\Client;
$Client = new Client();
/**
* @var \Symfony\Component\DomCrawler\Crawler
*/
$Crawler = $Client->request('GET', "https://play.google.com/store/apps/details?id=com.somago.brainoperator&hl=en");
$numberOfInstalls = $Crawler->filter('div.details-section-contents div.meta-info')->eq(1)->filter('div.content')->eq(0)->text();
echo $numberOfInstalls;它将简单地打印Brain Operator game的“下载次数”。
https://stackoverflow.com/questions/42350351
复制相似问题