forked from ahessmat/LinkedInfoSec
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandle.py
More file actions
48 lines (38 loc) · 1.03 KB
/
handle.py
File metadata and controls
48 lines (38 loc) · 1.03 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
47
48
#!/usr/bin/env python3
import argparse #needed for parsing commandline arguments
import os.path
import re
argp = argparse.ArgumentParser(description="Web Scraper meant for scraping certification information as it relates to InfoSec jobs off of LinkedIn")
argp.add_argument("-f", "--file", help="The filename to open and parse")
parsed=argp.parse_args()
filename = parsed.file
if not os.path.exists(filename):
argp.error("File doesn't exist")
d = {}
with open(f'{filename}', 'r') as f:
lines = f.readlines()
pattern = r"'([A-Za-z0-9_\./\\-]*)'"
for line in lines:
m = re.findall(pattern, line)
if len(m) > 0:
for e in m:
if e in d:
d[e] += 1
else:
d[e] = 1
res = dict(sorted(d.items(), key=lambda x: (-x[1], x[0])))
print(res)
"""
with open(f'pentester_certs.txt', 'r') as f:
lines = f.readlines()
certs = {}
for line in lines:
cert = line.split()
for c in cert:
if c in certs:
certs[c] += 1
else:
certs[c] = 1
res = dict(sorted(certs.items(), key=lambda x: (-x[1], x[0])))
print(res)
"""