-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlistwads.py
More file actions
executable file
·45 lines (31 loc) · 972 Bytes
/
Copy pathlistwads.py
File metadata and controls
executable file
·45 lines (31 loc) · 972 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
#!/usr/bin/env python3
import re, os, sys
import sre_constants
from urllib import request
BASENAME = os.path.basename(sys.argv[0])
USAGE = "{} <re>".format(BASENAME)
PARSERE = r''' +<a href=".+?">(.+?)</a> +? (\d{2}-[A-Za-z]{3}-\d{4}) (\d{2}:\d{2}) +([\d\.]+[GKM]?) +'''
PARSERE = re.compile(PARSERE)
def errorExit(reason):
print("{}: error: {}".format(BASENAME, reason))
sys.exit(1)
def usage():
print("usage:", USAGE)
def usageExit(reason):
print("{}: error: {}".format(BASENAME, reason))
usage()
sys.exit(128)
if len(sys.argv) < 2:
usageExit("needs an RE")
try:
matchRE = re.compile(sys.argv[1])
except sre_constants.error:
errorExit("invalid RE")
url = request.urlopen("http://wadhost.fathax.com/files")
derp = url.read().decode()
for line in derp.split("\n"):
match = PARSERE.match(line)
if match:
name, date, time, size = match.groups()
if matchRE.match(name):
print(name)