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


Python GooglePlayAPI.search方法代碼示例

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


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

示例1: main

# 需要導入模塊: from googleplay import GooglePlayAPI [as 別名]
# 或者: from googleplay.GooglePlayAPI import search [as 別名]
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,代碼行數:61,代碼來源:playweka.py

示例2: findAppInfo

# 需要導入模塊: from googleplay import GooglePlayAPI [as 別名]
# 或者: from googleplay.GooglePlayAPI import search [as 別名]
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,代碼行數:21,代碼來源:search.py

示例3: int

# 需要導入模塊: from googleplay import GooglePlayAPI [as 別名]
# 或者: from googleplay.GooglePlayAPI import search [as 別名]
    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,代碼行數:31,代碼來源:search.py

示例4: int

# 需要導入模塊: from googleplay import GooglePlayAPI [as 別名]
# 或者: from googleplay.GooglePlayAPI import search [as 別名]
     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,
                            
                c.details.appDetails.versionCode, # long type
                c.details.appDetails.versionString,   #unicode type
                c.details.appDetails.appCategory, # class type
                c.details.appDetails.installationSize, # long type
開發者ID:tyunist,項目名稱:google-play-crawler,代碼行數:33,代碼來源:search.py


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