-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract_permissions.py
49 lines (31 loc) · 1020 Bytes
/
extract_permissions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 5 12:01:53 2018
@author: gowtham
"""
from bs4 import BeautifulSoup
#download the webpage https://developer.android.com/reference/android/Manifest.permission and name it as android.html
html_doc = open('android.html', 'r')
soup = BeautifulSoup(html_doc, 'html.parser')
soup.prettify()
for link in soup.find_all('p'):
if "Constant Value:" in link.get_text():
#link.write(link.get_text()[15:])
print(link.get_text()[15:])
a = open('pernowr.csv', 'w')
import pandas as pd
permnow = pd.read_csv('Permissions_new.csv')
for i in permnow.iloc[:, 0].values:
a.write('android.permission.' + i + '\n')
a.close()
a = pd.read_csv('Permissions_new.csv', header = None)
b = pd.read_csv('Permissions.csv', header = None)
l = list(b.iloc[:, 0].values)
for i in list(a.iloc[:, 0].values):
if i not in l:
l.append(i)
c = open('Permissions.csv', 'w')
for i in l:
c.write(i + '\n')
c.close()