python

超轻量级php框架startmvc

python如何获取apk的packagename和activity

更新时间:2020-08-19 17:48:01 作者:startmvc
这篇文章主要介绍了python如何获取apk的packagename和activity,文中通过示例代码介绍的非常详细

这篇文章主要介绍了python如何获取apk的packagename和activity,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

实现代码如下:


# 找出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)

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

python apk packagename activity