http://apk-dl.comをダウンロードしてapkダウンロードリンクを取得することもできます。手順は、まずhttp://apk-dl.com/{packageName}
に行き、2つの連続したページでリンク値を抽出します。
HTMLを解析するためにダウンロードするcurlを使用し、pup bashの例は次のようになります。Pythonで
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 "";
}
:
#!/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"
はJavaでは、以下の方法は、APKのダウンロードURLを返す
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'))
ブラウザ拡張のコードは役に立ちますか? –
@Biju Parvathy okありがとうございますが、私はブラウザなしでapkをダウンしたいと思います。ちょうどapk urlを提供すると、自動的にダウンロードされます。 –
私の答えはブラウザ拡張とは異なります。 –