这篇文章主要介绍了python如何获取apk的packagename和activity,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
实现代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# 找出packagename和activity import os import re class packagename_activity: def get_packagename( self , path): aapt = [] os.system(f 'aapt dump badging {path}> ../xc_logs/AaptLog.txt' ) with open ( '../xc_logs/AaptLog.txt' , 'rb' ) as f: p1 = "package: name='(.+?)'" results1 = re.finditer(pattern = p1, string = f.readline().decode( 'utf-8' )) for r in results1: packagename = r.group( 1 ) aapt.append(packagename) p2 = "launchable-activity: name='(.+?)'" st = str (f.readlines()) results2 = re.findall(p2, st) activity = results2[ 0 ] aapt.append(activity) return aapt if __name__ = = '__main__' : a = packagename_activity() b = a.get_packagename( '../xc_apk/wangyiyunyinyue.apk' ) print (b) |
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:https://www.cnblogs.com/badbadboyyx/p/12163494.html