以编程方式从Google Play下载应用 [英] Download App from Google Play programmatically

查看:143
本文介绍了以编程方式从Google Play下载应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从Google Play下载一些应用程序以进行分析。但是,我不想手动进行操作(每次我要下载的应用程序更改时,我都必须经常这样做!)。

I need to download a few Apps from google play for analysis purpose. But I don't want to do it manually (I have to do it often and each time the Apps that I want to download change!).

所以,问题是是,是否可以编写程序下载应用程序。

So, the question is, whether I can write a program to download the Apps or not. If it is possible, how?

我见过适用于chrome的插件:
http://codekiem.com/2012/02/24/apk-downloader/
,但我不信任作者(该应用程序需要google用户并通过设备ID),并决定实现自己的程序。

I have seen this plugin for chrome: http://codekiem.com/2012/02/24/apk-downloader/ but I cannot trust the author (the App requires google user and pass and device ID) and have decide to implement my own program.

推荐答案

对于那些正在寻找Java实现的人它是:

For those of you who are looking for a Java implementation, here it is:

最高级步骤:


  1. 收集gmail ID,密码, Android ID和手机中的安全令牌

  2. 下载由Akdeniz实现的搜寻器的jar文件

  3. 下载googleplay.java的源文件( cli)来自Akdeniz

  4. 修改googleplay.java

  5. 将它们放在一起:D

  1. gather gmail ID, password, Android ID, and security token from your phone
  2. download the jar file for the crawler implemented by Akdeniz
  3. download the source file for googleplay.java (cli) from Akdeniz
  4. modify the googleplay.java
  5. put it all together :D

详细步骤:


  1. Gmail的ID和密码很明显!对于 Android ID ,请遵循 demirozali 并使用 getAndroidID功能。我无法使 getAuthToken工作!因此,我使用了 toxicbakery 获取安全令牌。请注意,应在 AsyncTask 不在UI线程上。

  1. Gmail ID and password are obvious! For Android ID follow the demirozali and use "getAndroidID" function. I could not make "getAuthToken" work! Therefore I used toxicbakery to get security token. Note that the function "updateToken" (which actually gets you the security token) should be called in an AsyncTask not on UI Thread.

来自 Akdeniz github网站下载 googleplaycrawler-0.1-SNAPSHOT.jar 文件。

我无法在jar文件中使用 GooglePlayAPI类。因此,我决定更改CLI版本。 googleplaycrawler-0.1-SNAPSHOT.jar中的CLI类称为 googleplay.java ,可以从源文件

I couldn't make use of "GooglePlayAPI" class in the jar file. So I decided to change the CLI version. The CLI class in "googleplaycrawler-0.1-SNAPSHOT.jar" is called "googleplay.java" which can be downloaded from the source files.

将 googleplay.java重命名为 Changed_googleplay.java 并进行修改。这样,方法 searchCommand()将返回String的arrayList,而不是在控制台上打印结果。

Rename "googleplay.java" to "Changed_googleplay.java" and modify it. Such that the method "searchCommand()" returns a arrayList of String, rather than printing the result on console.

已完成前面的所有步骤,请在jetBrains或...中创建一个项目,然后将 googleplaycrawler-0.1-SNAPSHOT.jar添加为库。另外,将 Changed_googleplay.java添加到您的src目录中。最后,在您的应用程序中使用以下方法。您可以使用以下类搜索查询,然后下载与该查询相对应的所有免费应用。

Having done all the previous steps, create a project in jetBrains or ... and add "googleplaycrawler-0.1-SNAPSHOT.jar" as a library. Also, add "Changed_googleplay.java" to your src directory. Finally use the following method in your application. You can use the following class to search a query and then download all Free Apps corresponding to that query.

public void SearchAndDownload() {
    String login = "xxxx@gmail.com";
    String password = "xxxx";
    String androidId = "xxxx";
    String securitytoken = "xxxx";
    String command = "search";
    String query = "Maps";
    String offest = "0";
    String number = "5";

    Changed_googleplay gp = new Changed_googleplay();
    ArrayList<String> res = gp.operate(new String[]{"-i", androidId, "-e", login, "-p", password, "-t", securitytoken, command, "-o", offest, "-n", number, query});

    res.remove(0);
    if (command.equals("search")) {
        System.out.println("Title"+"\t"+"Package Name"+"\t"+"Price"+"\t"+"Number of Downloads");
        for (String line : res){
            String[] split = line.split(Changed_googleplay.DELIMETER);
            String name = split[0];
            String packageName = split[1];
            String creator = split[2];
            String price = split[3];
            String size = split[4];
            String dlNO = split[5];
            if(price.equals("Free")){
                System.out.println(name+"\t"+packageName+"\t"+price+"\t"+dlNO);
                gp.operate(new String[]{"-i", androidId, "-e", login, "-p", password, "-t", securitytoken, "download", packageName});
            }
        }
    }
}


您可能想看看爬虫项目主页

You may want to take a look at the list of command line options in the crawler project main page.

玩得开心!

这篇关于以编程方式从Google Play下载应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆