本文整理汇总了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
示例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)
示例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)
示例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