當前位置: 首頁>>代碼示例>>Python>>正文


Python googleplay.GooglePlayAPI類代碼示例

本文整理匯總了Python中googleplay.GooglePlayAPI的典型用法代碼示例。如果您正苦於以下問題:Python GooglePlayAPI類的具體用法?Python GooglePlayAPI怎麽用?Python GooglePlayAPI使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了GooglePlayAPI類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: download

def download():
    package = args.package
    filename = package + ".apk"

    # Connect
    api = GooglePlayAPI(args.device, lang='en_US')
    api.login(args.email, args.password, None)

    # Get the version code and the offer type from the app details
    m = api.details(package)
    doc = m.docV2
    vc = doc.details.appDetails.versionCode
    ot = doc.offer[0].offerType

    # Download
    if args.target_arch:
        str_target_arch = '-%s' % args.target_arch
    else:
        str_target_arch = ''
    filename = '%s%s-%s.apk' % (get_datetime(), str_target_arch, package)
    dir_out = args.dir_out
    if dir_out:
        filename = dir_out + '/' + filename

    data = api.download(package, vc, ot)
    open(filename, "wb").write(data)
開發者ID:Sgtransporterall,項目名稱:share,代碼行數:26,代碼來源:apk.py

示例2: Downloader

class Downloader():

    def __init__(self):
        self.api = GooglePlayAPI(ANDROID_ID)
        self.api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

    def download(self, pkg, filename):
        doc = self.api.details(pkg).docV2
        vc = doc.details.appDetails.versionCode

        data = self.api.download(pkg, vc)
        with open(filename, 'wb') as apk:
            apk.write(data)

    def downloadall(self, dbname, outdir, maxsize=None):
        mkdir(outdir)
        with sqlite3.connect(dbname, timeout=10) as db:
            with closing(db.cursor()) as cur:
                cur.execute(create)
                for pkg, size in cur.execute(select).fetchall():
                    print 'Processing %s (%s) ...' % (pkg, size)
                    if not sizeallowed(size, maxsize):
                        print Fore.YELLOW + '  [SKIP: too big (%s)]' % size
                        continue
                    path = os.path.join(outdir, pkg + '.apk')
                    try:
                        self.download(pkg, path)
                    except Exception as e:
                        print Fore.RED + '  [ERROR: %s]' % e.message
                    else:
                        print Fore.GREEN + '  [OK: downloaded to %s]' % path
                        cur.execute(insert, (pkg, path))
                        db.commit()
開發者ID:enricobacis,項目名稱:playscraper,代碼行數:33,代碼來源:downloader.py

示例3: main

def main():
    search_term = sys.argv[1]
    '''
    apps will be a list of dicts describing each returned app:
    {'app_name':<app name>,'app_id':<app id>,'app_creator':<creator>,'app_permissions':[list]}
    '''
    apps = []
    nb_res = 100 # apps to retrieve. API allows for max of 100.
    offset = 0 
    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
    try:
        message = api.search(search_term, nb_res, offset)
    except:
        print "Error: something went wrong. Google may be throttling or rejecting the request."
        sys.exit(1)

    doc = message.doc[0]
    for c in doc.child:
        permissions = []
        details = api.details(c.docid)
        for line in details.docV2.details.appDetails.permission:
            permissions.append(line)
        apps.append({'app_name':c.title,'app_id':c.docid,'app_creator':c.creator,'app_permissions':permissions})

    '''
    We are interested in the set of all possible permissions that start with 'ANDROID.'
    '''
    permissions = Set([])
    for app in apps:
        for permission in app["app_permissions"]:
            if  permission.upper()[0:8] == "ANDROID.":
                permissions.add(permission.upper())

    '''
    Create ARFF output for Weka
    '''
    dataset = open(search_term + ".arff",'w')
    dataset.write("@relation Appdata\n")
    dataset.write("@attribute index NUMERIC\n")
    dataset.write("@attribute app_name STRING\n")
    for att in permissions:
        dataset.write("@attribute "+ att + " {0,1}\n")
    dataset.write("@data\n")
    i = 0 # index for cross-referencing
    for app in apps:
        print("{} {}").format(str(i), str(app)) # index
        perm_str = str(i) + ',' + app['app_id'] + ','
        app_perm_upper = []
        for app_permission in app['app_permissions']:
            app_perm_upper.append(app_permission.upper())
        for permission in permissions:
            if permission in app_perm_upper:
                perm_str = perm_str + '1,'
            else:
                perm_str = perm_str + '0,'
        dataset.write(perm_str[:-1])
        dataset.write("\n")
        i += 1
開發者ID:tvldz,項目名稱:playweka,代碼行數:59,代碼來源:playweka.py

示例4: login

def login():
    api = None
    try:
        api = GooglePlayAPI(ANDROID_ID)
        api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
    except Exception as e:
        print e
    return api
開發者ID:adrooy,項目名稱:PycharmProjects,代碼行數:8,代碼來源:test.py

示例5: connect

def connect(android_id, google_login, google_password, auth_token):
    api = GooglePlayAPI(android_id)
    try:
      api.login(google_login, google_password, auth_token)
    except:
      print >> sys.stderr, int(time.time()) 
      traceback.print_exc(file=sys.stderr)
    return api
開發者ID:CMUChimpsLab,項目名稱:googleplay-api,代碼行數:8,代碼來源:download.py

示例6: login

def login(logger):
    api = None
    try:
        api = GooglePlayAPI(ANDROID_ID)
        api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
    except Exception as e:
        logger.debug('login google error %s' % e)
    return api
開發者ID:adrooy,項目名稱:shell,代碼行數:8,代碼來源:new.py

示例7: scrape

def scrape(id, package):

    packagename = package
    res = urllib2.urlopen("https://play.google.com/store/apps/details?id=%s&hl=en" % packagename)
    html = res.read()

    path = "assets/%d/" % id
    if not os.path.exists(path):
        os.makedirs(path)

    name = html.split('itemprop="name"')[1].split("</div>")[0].split("<div>")[1]
    desc = html.split('<div class="show-more-content text-body" itemprop="description">')[1].split(
        '<div class="show-more-end">'
    )[0]
    rating = html.split("Rated ")[1].split(" stars")[0]
    category = html.split('<span itemprop="genre">')[1].split("</span>")[0]

    stuff = []
    for line in html.split("</div>"):
        if "full-screenshot" in line:
            url = line.split('src="')[1][:-3]
            stuff.append(url)

    x = 0
    for img in stuff[1:]:
        print img
        urllib.urlretrieve(img, "%s%d.webp" % (path, x))
        x += 1

    filename = path + packagename + ".apk"

    # Connect
    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

    # Get the version code and the offer type from the app details
    m = api.details(packagename)
    doc = m.docV2
    vc = doc.details.appDetails.versionCode
    ot = doc.offer[0].offerType

    # Download
    print "Downloading %s..." % sizeof_fmt(doc.details.appDetails.installationSize),
    data = api.download(packagename, vc, ot)
    open(filename, "wb").write(data)
    print "Done"
    ap = apk.APK(filename)
    badging = os.popen("/home/thomas/dev/android-odroid/out/host/linux-x86/bin/aapt dump badging %s" % filename).read()
    for line in badging.split("\n"):
        if "launchable-activity" in line:
            activity = line.split("'")[1]

    return [name, desc, rating, package, activity, category]
開發者ID:tliu,項目名稱:mnectar_discovery_backend,代碼行數:53,代碼來源:scrape.py

示例8: download_apk

def download_apk(packagename, filename):
    # Connect
    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

    # Get the version code and the offer type from the app details
    m = api.details(packagename)
    doc = m.docV2
    vc = doc.details.appDetails.versionCode
    ot = doc.offer[0].offerType

    # Download
    print "Downloading %s..." % sizeof_fmt(doc.details.appDetails.installationSize),
    data = api.download(packagename, vc, ot)
    open(filename, "wb").write(data)
    print "Done"
開發者ID:MingIsCoding,項目名稱:CMPE281_SVR,代碼行數:16,代碼來源:download.py

示例9: login

def login(id, mail, password, token):
	""" Login to the Google Play Store.
		
		You can either specify the mail and password, or use
		a valid auth token.
		
		Arguments:
		id       -- the android phone ID
		mail     -- the email address of the account
		password -- the password of the account
		token    -- a valid auth token
		
		Returns:
		A Google Play API object.
		"""
	api = GooglePlayAPI(id)
	api.login(mail, password, token)
	return api
開發者ID:ephracis,項目名稱:hermes,代碼行數:18,代碼來源:store.py

示例10: downloadAPKs

def downloadAPKs(start):
    crawler = CrawlerThread("../playapks/", startappID)
    crawler.start()
    time.sleep(1)

    threads = []

    playapi = GooglePlayAPI()
    playapi.login("[email protected]", "niklashaxor42")

    for i in range(4): # 4 download threads
        t = DownloadThread(appQueue, "../playapks/", playapi)
        t.start()
        threads.append(t)

    filewriter = FileThread()
    filewriter.start()

    done = False
    #OMG DON'T DIE!
    while not done:
        test = raw_input(">")
        if test == "exit":
            print "Killing threads..."
            for thread in threads:
                thread.stop()
            crawler.stop()
            filewriter.stop()
            while len([t for t in threads if t.stopped == True]):
                time.sleep(1)
                print "Waiting for threads to finish..."
            print "Exiting..."
            done = True


    if os.path.exists("queue.txt"):
        os.remove("queue.txt")

    queueFile = open("queue.txt", 'w')

    for a in list(appQueue.queue):
        queueFile.write(a+"\n")

    queueFile.close()
開發者ID:Ragnara5799,項目名稱:SIFTA,代碼行數:44,代碼來源:scraper.py

示例11: list

def list(cat, ctr = None, nb_results = None, offset = None):
    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
    try:
        message = api.list(cat, ctr, nb_results, offset)
    except:
        print "Error: HTTP 500 - one of the provided parameters is invalid"

    if (ctr is None):
        print SEPARATOR.join(["Subcategory ID", "Name"])
        for doc in message.doc:
            print SEPARATOR.join([doc.docid.encode('utf8'), doc.title.encode('utf8')])
    else:
        print_header_line()
        doc = message.doc[0]
        results = []
        for c in doc.child:
            results.append(get_parsed_result(c))
        return results
開發者ID:bdsword,項目名稱:googleplay-api,代碼行數:19,代碼來源:list.py

示例12: findAppInfo

def findAppInfo(packageName):
    request = packageName
    nb_res = None
    offset = None

    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

    try:
        message = api.search(request, nb_res, offset)
        doc = message.doc[0]
        for c in doc.child:
            if c.docid.startswith(packageName):
                result = {}
                result["creator"] = c.creator
                result["price"] = c.offer[0].formattedAmount
                return result
    except Exception, e:
        print str(e)
開發者ID:MingIsCoding,項目名稱:CMPE281_SVR,代碼行數:19,代碼來源:search.py

示例13: int

    print "Usage: %s request [nb_results] [offset]" % sys.argv[0]
    print "Search for an app."
    print "If request contains a space, don't forget to surround it with \"\""
    sys.exit(0)

request = sys.argv[1]
nb_res = None
offset = None

if (len(sys.argv) >= 3):
    nb_res = int(sys.argv[2])

if (len(sys.argv) >= 4):
    offset = int(sys.argv[3])

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

try:
    message = api.search(request, nb_res, offset)
except:
    print "Error: something went wrong. Maybe the nb_res you specified was too big?"
    sys.exit(1)

print_header_line()
print message
doc = message.doc[0]
for c in doc.child:
    print_result_line(c)

開發者ID:joshuasteven,項目名稱:google-play-crawler-master,代碼行數:29,代碼來源:search.py

示例14: __init__

 def __init__(self):
     self.api = GooglePlayAPI(ANDROID_ID)
     self.api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
開發者ID:enricobacis,項目名稱:playscraper,代碼行數:3,代碼來源:downloader.py

示例15: int



if (len(sys.argv) >= 3):
     NB_RES = int(sys.argv[2])

if (len(sys.argv) >= 4):
     OFFSET = int(sys.argv[3])
    
# Check request content   
print "Request:", request
print "Number of request:", NB_RES
print "Offset:", OFFSET


api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
print "NB_RES/OFFSET:",NB_RES/OFFSET
for i in range (50):
    message = api.search(request, str(NB_RES), str(i*NB_RES))
    doc = message.doc[0]
    for c in doc.child:
        print c
        l = [           
                # unicode type
                c.docid,
                c.title,
                c.creator,
                c.descriptionHtml, # need to remove control characters
                c.offer[0].formattedAmount,
                            
開發者ID:tyunist,項目名稱:google-play-crawler,代碼行數:27,代碼來源:search.py


注:本文中的googleplay.GooglePlayAPI類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。