-
-
Save Oshanmateesha2/164a8d3aa8af8bf8d216e6639d2c18f4 to your computer and use it in GitHub Desktop.
Revisions
-
dawand revised this gist
May 27, 2019 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,10 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """ File name: download_apk.py Author: Dawand Sulaiman Download APK files from Google Play Store with Python This script scraps https://apkpure.com to get the apk download link Make sure you have BeautifulSoup and urllib libraries """ -
dawand revised this gist
May 27, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """Download APK files from Google Play Store with Python This script scraps https://apkpure.com to get the apk download link Make sure you have BeautifulSoup and urllib libraries """ -
dawand created this gist
May 27, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """Download APK files from Google Play Store using Python Note that all the APKs are grabbed from https://apkpure.com Make sure you have BeautifulSoup and urllib libraries """ from bs4 import BeautifulSoup from urllib.parse import quote_plus import requests def search(query): res = requests.get('https://apkpure.com/search?q={}®ion='.format(quote_plus(query)), headers={ 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.5 (KHTML, like Gecko) ' 'Version/9.1.2 Safari/601.7.5 ' }).text soup = BeautifulSoup(res, "html.parser") search_result = soup.find('div', {'id': 'search-res'}).find('dl', {'class': 'search-dl'}) app_tag = search_result.find('p', {'class': 'search-title'}).find('a') download_link = 'https://apkpure.com' + app_tag['href'] return download_link def download(link): res = requests.get(link + '/download?from=details', headers={ 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.5 (KHTML, like Gecko) ' 'Version/9.1.2 Safari/601.7.5 ' }).text soup = BeautifulSoup(res, "html.parser").find('a', {'id': 'download_link'}) if soup['href']: r = requests.get(soup['href'], stream=True, headers={ 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.5 (KHTML, like Gecko) ' 'Version/9.1.2 Safari/601.7.5 ' }) with open(link.split('/')[-1] + '.apk', 'wb') as file: for chunk in r.iter_content(chunk_size=1024): if chunk: file.write(chunk) def download_apk(app_id): download_link = search(app_id) if download_link is not None: print('Downloading {}.apk ...'.format(download_link)) download(download_link) print('Download completed!') else: print('No results') # Test it download_apk('org.moire.opensudoku')