简体   繁体   English

是否有可能以编程方式将谷歌从谷歌下载到PC?

[英]Is it possible to download apk from google play programmatically to PC?

I'd like to download a lot of apks from google play to PC and install apk on phone for test. 我想从谷歌播放下载很多apks到PC并在手机上安装apk进行测试。

I have seen that http://apk-dl.com/ can download an apk to pc, so is it possible to do the same thing by using java or python or have some code examples? 我已经看到http://apk-dl​​.com/可以下载一个apk到PC,所以有可能通过使用java或python做一些相同的事情或有一些代码示例?

Use Google Play Unofficial Python API (github) 使用Google Play非官方Python API (github)

Using this API you can download APKs using their package name: 使用此API,您可以使用其包名称下载APK:

python download.py com.google.android.gm

For finding relevant APKs you can use the search or even parse subcategories 要查找相关的APK,您可以使用搜索甚至解析子类别

python search.py earth
python list.py WEATHER apps_topselling_free

You could also scrap http://apk-dl.com to get the apk download link, the steps include to first go to http://apk-dl.com/{packageName} and extract the link value in 2 consecutive pages. 你也可以废弃http://apk-dl​​.com获取apk下载链接,步骤包括首先访问http://apk-dl.com/{packageName}并连续2页提取链接值。

A bash example that uses curl to download and pup to parse HTML would be : 使用curl下载和pup来解析HTML的bash示例将是:

#!/bin/bash

package=com.facebook.katana

# Download APK 
temp_link=$(curl -s "http://apk-dl.com/$package" | pup ".download-btn .mdl-button attr{href}")
temp2_link=$(curl -s "http://apk-dl.com/$temp_link" | pup ".detail a attr{href}")
dl_link=$(curl -s "$temp2_link" | pup ".contents a attr{href}")

rm -f app.apk
curl -s -o app.apk "http:$dl_link"

In Java, the following method return the apk download url : 在Java中,以下方法返回apk下载URL:

public static String getApkDownloadUrl(final String packageName) throws IOException {

    Elements data = Jsoup.connect("http://apk-dl.com/" + packageName).get().select(".download-btn .mdl-button");

    if (data.size() > 0) {

        Elements data2 = Jsoup.connect("http://apk-dl.com" + data.attr("href")).get()
                .select(".detail a");

        if (data2.size() > 0) {

            Elements data3 = Jsoup.connect(data2.attr("href")).get()
                    .select(".contents a");

            return (data3.size() > 0) ? "http:" + data3.attr("href") : "";
        }
    }
    return "";
}

In Python : 在Python中:

import urllib2
from bs4 import BeautifulSoup
import re

def get_apk_url(package_name): 
    opener = urllib2.build_opener()

    response = opener.open('http://apk-dl.com/' + package_name)
    soup = BeautifulSoup(response.read(), 'html.parser')
    temp_link = soup.find("div",{'class': 'download-btn'}).find("a")["href"]

    response = opener.open('http://apk-dl.com/' + temp_link)
    soup = BeautifulSoup(response.read(), 'html.parser')
    temp_link2 = soup.find("section",{'class': 'detail'}).find("a")["href"]

    response = opener.open(temp_link2)
    soup = BeautifulSoup(response.read(), 'html.parser')
    temp_link3 = soup.find("div",{'class': 'contents'}).find("a")["href"]

    return "http:" + temp_link3

print(get_apk_url('com.facebook.katana'))

在Java中试用: Google Play Downloader

If you're a more casual APK downloader then a Chrome extension is probably not really necessary. 如果你是一个更随意的APK下载程序,那么Chrome扩展程序可能不是真的必要。 Instead, you can just visit a dedicated site for generating APK download links whenever you need to. 相反,您可以随时访问专用网站以生成APK下载链接。

Go to the Play Store and find the app you want to download. 转到Play商店,找到您要下载的应用。 Copy the app's URL address from the browser's address bar. 从浏览器的地址栏复制应用程序的URL地址。 Next, go to a site like Apk16 APK Downloader (Apk16 also has a Chrome/Firefox extension) and paste the app package name (or the whole Google Play URL if you're lazy) in the box at the top of the page. 接下来,转到Apk16 APK Downloader (Apk16也有Chrome / Firefox扩展程序)这样的网站,并在页面顶部的框中粘贴应用程序包名称(或者如果你懒的话,粘贴整个Google Play URL)。

Projects wrapping API interaction are either obsolete or fail when Google requires to verify actions in browser. 当Google要求在浏览器中验证操作时,包含API交互的项目要么已过时,要么失败。 I found it convenient to write a script in UiAutomator. 我发现在UiAutomator中编写脚本很方便。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM