Java 没有API时如何获取Android Market数据?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1308346/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 08:04:50  来源:igfitidea点击:

How to fetch Android Market data when there is no API?

javaandroid

提问by allclaws

As far as I can tell, there is no API (official or unofficial) to access information about Apps on the Android Market (info such as Title, Icon, Description, Downloads, Comments, etc..) However, there are a few websitesthat have managed to compile this information anyway.

据我所知,没有 API(官方或非官方)可以访问 Android Market 上有关应用程序的信息(例如标题、图标、描述、下载、评论等信息。)但是,有一些网站无论如何都设法编译了这些信息。

My question is: How is this being done?

我的问题是:这是如何做到的?

A couple of guesses.

几个猜测。

  • Manually (not likely, due to volume)
  • Implemented the protocol used by the official app (by decompiling or observing packets)
  • Running some kind of debugger with the official app to extract the live data
  • Using some kind of automation + screen shots + text recognition (seems complicated)
  • Modifying the (open) source to write a log file
  • 手动(不太可能,由于体积)
  • 实现官方应用使用的协议(通过反编译或观察数据包)
  • 使用官方应用程序运行某种调试器以提取实时数据
  • 使用某种自动化+屏幕截图+文本识别(看起来很复杂)
  • 修改(打开)源以写入日志文件

I'm just curious how this was done because I sure can't figure it out. Thanks.

我只是好奇这是如何完成的,因为我肯定无法弄清楚。谢谢。

采纳答案by Jan Berkel

There is a Java project on Google code which attempts to build an open source api for the market: http://code.google.com/p/android-market-api/

有一个关于 Google 代码的 Java 项目试图为市场构建一个开源 api:http: //code.google.com/p/android-market-api/

There're also some JRuby bindings for it: http://github.com/jberkel/supermarket.

还有一些 JRuby 绑定:http: //github.com/jberkel/supermarket

However they both require a Google/Market account, and the API is only partially implemented (searching, comments and images at the moment). Also, the reconstructed protocol buffer descriptor (market.proto) could be used to generate bindings for languages other than Java.

但是,它们都需要 Google/Market 帐户,并且 API 仅部分实现(目前搜索、评论和图像)。此外,重建的协议缓冲区描述符 (market.proto) 可用于为 Java 以外的语言生成绑定。

回答by yanchenko

As far as I know, they are using Protocol Buffers. You'll have to sniff phone traffic while it's accessing the market connected over wifi.

据我所知,他们正在使用Protocol Buffers。在访问通过 wifi 连接的市场时,您必须嗅探电话流量。

回答by Marc Climent

Another option to capture data is using the tcpdumptool that comes with some custom images (like Cyanogenmodand others). You can capture all the packets and then analyze them using Wireshark. This route is easier than hiHymaning wifi.

捕获数据的另一种选择是使用一些自定义图像(如Cyanogenmod等)附带的tcpdump工具。您可以捕获所有数据包,然后使用Wireshark对其进行分析。这条路线比劫持wifi容易。

Checkout this splendid posts to clear out some things:

查看这个精彩的帖子以清除一些东西:

UpdateI have been working on this a bit more and @gsmd is right and they use Protocol Buffersto transfer the information and with the technique described above you can capture the packets. Then you'll need to dig into protobuffers to understand the messages.

更新我一直在做更多的工作,@gsmd 是正确的,他们使用协议缓冲区来传输信息,并且使用上述技术您可以捕获数据包。然后你需要深入研究 protobuffers 来理解消息。

回答by peterkodermac

There is a really good way of getting data from the Developer console. Take a look at: https://github.com/tmurakam/googleplay_dev_scraper

有一种从开发者控制台获取数据的好方法。看一看:https: //github.com/tmurakam/googleplay_dev_scraper

I have it running on my raspberry pi and it works really good. It's pretty simple to install and further automate it with a bash script. I'd really recommend this scraper to anyone interested in getting data from the developer console!

我让它在我的 raspberry pi 上运行,效果非常好。使用 bash 脚本安装和进一步自动化它非常简单。我真的向任何有兴趣从开发者控制台获取数据的人推荐这个抓取工具!

回答by SteveEdson

Google have recently added official support for this. Reports are exported to a Google cloud storage bucket

谷歌最近为此增加了官方支持。报告导出到 Google 云存储桶

See https://support.google.com/googleplay/android-developer/answer/6135870?hl=en&ref_topic=3450942for more information.

有关详细信息,请参阅https://support.google.com/googleplay/android-developer/answer/6135870?hl=zh-CN&ref_topic=3450942

回答by agirardello

Unfortunately there is still no official API for Google Play Store (previously known as Android Market) to access Android apps' meta-data (or any other stats).

不幸的是,Google Play 商店(以前称为 Android Market)仍然没有官方 API 来访问 Android 应用程序的元数据(或任何其他统计数据)。

As mentioned in other answers, you could develop your own web crawler, parse the HTML page and extract the app meta-data you need (e.g. title, descriptions, price, etc). This topic has been covered in this other question.

正如其他答案中提到的,您可以开发自己的网络爬虫,解析 HTML 页面并提取您需要的应​​用元数据(例如标题、描述、价格等)。此主题已在另一个问题中涵盖。

Another option is to use an open-source library based on ProtoBuf to fetch meta-data about an app, here the link to the project: https://code.google.com/archive/p/android-market-api. This library fetches app meta-data from Google Play on behalf of a valid Google account, but you still need a crawler to "find" which apps are available and schedule their meta-data retrieval. This other open-source project can help you with that: https://code.google.com/archive/p/android-marketplace-crawler.

另一种选择是使用基于 ProtoBuf 的开源库来获取有关应用程序的元数据,这里是项目的链接:https: //code.google.com/archive/p/android-market-api。该库代表有效的 Google 帐户从 Google Play 获取应用程序元数据,但您仍然需要一个爬虫来“查找”哪些应用程序可用并安排它们的元数据检索。这个另一个开源项目可以帮助你:https: //code.google.com/archive/p/android-marketplace-crawler

If you don't want to implement all that by yourself, you could use a third-party service to access Android apps meta-data through a JSON-based API. For instance, 42matters.com(the company I work for) offers an API for both Android and iOS to retrieve apps' meta-data, here more details:

如果您不想自己实现所有这些,您可以使用第三方服务通过基于JSON 的 API访问 Android 应用程序元数据。例如,42matters.com(我工作的公司)为 Android 和 iOS 提供了一个 API 来检索应用程序的元数据,这里有更多详细信息:

https://42matters.com/app-market-data

https://42matters.com/app-market-data

In order to get the Title, Icon, Description, Downloads for an app you can use the "lookup" endpoint as documented here:

为了获得应用程序的标题、图标、描述、下载,您可以使用此处记录的“查找”端点:

https://42matters.com/docs/app-market-data/android/apps/lookup

https://42matters.com/docs/app-market-data/android/apps/lookup

This is an example of the JSON response for the "Angry Birds Space Premium" app:

这是“Angry Birds Space Premium”应用的 JSON 响应示例:

{
    "package_name": "com.rovio.angrybirdsspace.premium",
    "title": "Angry Birds Space Premium",
    "description": "Play over 300 interstellar levels across 10 planets...",
    "short_desc": "The #1 mobile game of all time blasts off into space!",
    "rating": 4.3046236038208,
    "category": "Arcade",
    "cat_key": "GAME_ARCADE",
    "cat_keys": [
        "GAME_ARCADE",
        "GAME",
        "FAMILY_EDUCATION",
        "FAMILY"
    ],
    "price": ".15",
    "downloads": "1,000,000 - 5,000,000",
    "version": "2.2.1",
    "content_rating": "Everyone",
    "promo_video": "https://www.youtube.com/embed/g6AL9YqRHaI?ps=play&vq=large&rel=0&autohide=1&showinfo=0&autoplay=1",
    "market_update": "2015-07-03T00:00:00+00:00",
    "screenshots": [
        "https://lh3.googleusercontent.com/ZmuBQzIy1G74coPrQ1R7fCeKdJmjTdpJhNrIHBOaFyM0N2EYdUPwZaQjnQUtiUDGmac=h310",
        "https://lh3.googleusercontent.com/Xg2Aq70ZH0SnNhtSKH7xg9jCfisWgmmq3C7xQbx6YMhTVAIRqlRJeH8GYtjxapb_qR4=h310",
        "https://lh3.googleusercontent.com/T4o5-2_UP82sj4fSSegbjrGmslNHlfvtEYuZacXMSOC55-7eyiKySw05lNF1QQGO2FeU=h310",
        "https://lh3.googleusercontent.com/f2ennaLdivFu5cQQaVPKsRcWxB8FS5T4Bkoy3l0iPW9-GDDnTVRhvR5kz6l4m8FL1c8=h310",
        "https://lh3.googleusercontent.com/H-9M03_-O9Df1nHr2-rUdjtk2aeBY3bAxnqSX3m2zh_aV8-K1t0qU1DxLXnK0GrDAw=h310"
    ],
    "created": "2012-03-22T08:24:00+00:00",
    "developer": "Rovio Entertainment Ltd.",
    "number_ratings": 20812,
    "price_currency": "$",
    "icon": "https://lh3.ggpht.com/aQaIEGrmba1ENSEgUtArdm3yhJUug7BRWlu_WaspoJusZyHv1rjlWtYqe_qRjE_Kmh1E=w300",
    "icon_72": "https://lh3.ggpht.com/aQaIEGrmba1ENSEgUtArdm3yhJUug7BRWlu_WaspoJusZyHv1rjlWtYqe_qRjE_Kmh1E=w72",
    "market_url": "https://play.google.com/store/apps/details?id=com.rovio.angrybirdsspace.premium&referrer=utm_source%3D42matters.com%26utm_medium%3Dapi"
}

Alternatively, we also have a DATA FEED DUMPto access all mobile app data at once: https://42matters.com/docs/app-market-data/file-dump/android-app-details(on this page you can also find a free sample of data for your tests).

或者,我们还有一个DATA FEED DUMP可以一次访问所有移动应用程序数据:https: //42matters.com/docs/app-market-data/file-dump/android-app-details(在此页面上,您也可以为您的测试找到免费的数据样本)。

I hope this helps, otherwise feel free to get in touch with me. I know this topic quite well and can point you in the right direction.

我希望这会有所帮助,否则请随时与我联系。我非常了解这个主题,可以为您指明正确的方向。

Regards,

问候,

Andrea

安德烈亚