forked from CovidVaccine19qr/pentesterhelper.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapiCount.py
More file actions
46 lines (42 loc) · 1.31 KB
/
apiCount.py
File metadata and controls
46 lines (42 loc) · 1.31 KB
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
import json
import sys
def uses():
print("Uses:")
print("1. python3 apiCount.py jsonfile.json")
print("Extracting API with Different Methods and Counting All extracting API with Methods")
print("2. python3 apiCount.py jsonfile.json --api")
print("Extracting API without Methods and Counting All extracting API without Methods")
n = len(sys.argv)
try:
if(n==2):
filePath = sys.argv[1]
f = open(filePath)
data = json.load(f)
count = 0
for i in data['paths']:
apiList = i
apiMethod = json.dumps(data['paths'][apiList])
apiMethodJson = json.loads(apiMethod)
for i in apiMethodJson:
if(i!='parameters'):
count = count+1
print(i+' '+apiList)
print("Total: " + str(count))
f.close()
if(n==3):
filePath = sys.argv[1]
if(sys.argv[2]=="--api"):
f = open(filePath)
data = json.load(f)
count = 0
for i in data['paths']:
count = count+1
print(i)
print("Total: " + str(count))
else:
print("--api command")
uses()
else:
uses()
except:
uses()