Skip to content

Instantly share code, notes, and snippets.

@worldofprasanna
Created November 22, 2019 11:06
Show Gist options
  • Save worldofprasanna/c7d2f91eebf7e686a6f65a90da64d192 to your computer and use it in GitHub Desktop.
Save worldofprasanna/c7d2f91eebf7e686a6f65a90da64d192 to your computer and use it in GitHub Desktop.
Download APK files from google play store
import sys
import os
from gpapi.googleplay import GooglePlayAPI
def main():
server = GooglePlayAPI('en_US', 'America/New York', 'bacon')
try:
server.login(email="<gmail userid>", password="<gmail password>")
storagepath = '/tmp/'
download = server.download('com.whatsapp', expansion_files=False)
apkpath = os.path.join(storagepath, download['docId'] + '.apk')
if not os.path.isdir(storagepath):
os.makedirs(storagepath)
with open(apkpath, 'wb') as first:
print('Downloading ' + download['docId'] + '.apk.....')
for chunk in download.get('file').get('data'):
first.write(chunk)
print('APK downloaded and stored at ' + apkpath)
except Exception as err:
print("Login failed. Ensure that correct credentials are provided. {0}".format(err))
sys.exit(1)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment