-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextract_comments.py
More file actions
30 lines (24 loc) · 880 Bytes
/
Copy pathextract_comments.py
File metadata and controls
30 lines (24 loc) · 880 Bytes
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
import sys
file = str(sys.argv[1])
Incom = False
with open('comments.txt', "w", encoding="utf-8") as fl:
#fl.write(html.decode('utf-8'))
with open(file, encoding="utf-8") as f:
lines = f.readlines()
for line in lines:
res = line.split()
for i in res:
if(i[:3] == '<p>'):
Incom = True
if(i[-4:] == '</p>'):
Incom = False
if((Incom == True) and (i[:3] == '<p>')):
#print(i[3:], end=" ")
fl.write(i[3:])
elif (Incom == True):
#print(i, end=" ")
fl.write(i)
elif ((Incom == False) and (i[-4:] == '</p>')):
#print(i[:-4])
fl.write(i[:-4])
#print(line)