- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp-data.py
More file actions
Latest commit
50 lines (35 loc) · 795 Bytes
/
Copy pathhttp-data.py
File metadata and controls
50 lines (35 loc) · 795 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
importrequests
importhtml2text
fromcollectionsimportCounter
importargparse
importre
if__name__=="__main__":
parser=argparse.ArgumentParser()
parser.add_argument('--url', help='Enter URL', dest='u')
args=parser.parse_args()
printargs.u
r=requests.get(args.u);
printr.status_code
htmltext=r.content
plaintext=html2text.html2text(htmltext)
words=plaintext.split()
counts=Counter(words)
# print counts
f=open('workfile', 'w')
f.write(str(counts))
lines=plaintext.splitlines()
k= []
v= []
# a, b = re.split('\W+',lines[1],1)
# print a
# print b
foriinrange(0,len(lines)):
test=1
try:
s=lines[i].lstrip()
a, b=re.split(r'\t+',s,1)
exceptValueError:
test=0
iftest==1:
k.append(a)
v.append(b)