-
-
Notifications
You must be signed in to change notification settings - Fork 154
/
Copy pathparsers.sh
executable file
·64 lines (55 loc) · 1.68 KB
/
parsers.sh
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# get groups with parsers enabled
# jq -r '.[] | select(.parser==true) | .name' groups.json
# get groups with captcha
# jq -r '.[] | select(.captcha==true) | .name' groups.json
if [ "${1}" == "-h" ]; then
echo "by default - will run very basic checks on each parser and report on those not returning anything"
echo "switch: print all parsers | -p"
echo "switch: print specific group | -p <groupname>"
exit 0
fi
shell_parsers=`grep -A 2 "parser = '''" parsers.py | sed -e "/parser = '''/d" -e "/'''/d" -e '/^--$/d'`
shell_parsers_total=`echo "${shell_parsers}" | wc -l | sed -e 's/^[ \t]*//'`
echo "checking each parser is returning results (line-delim posts)"
echo
if [ "${1}" == "-p" ] && [ "${2}" != "" ]; then
while read -r line; do
if [[ ${line} =~ %s ]]; then
line=${line//%s/grep -oE}
fi
if [[ ${line} =~ ${2} ]]; then
echo ${line}
fi
done <<< "${shell_parsers}"
exit 0
fi
if [ "${1}" == "-p" ]; then
while read -r line; do
if [[ ${line} =~ %s ]]; then
line=${line//%s/grep -oE}
fi
echo ${line}
done <<< "${shell_parsers}"
exit 0
fi
brokecount=0
while read -r line; do
if [[ ${line} =~ %s ]]; then
line=${line//%s/grep -oE}
fi
if [[ ${line} =~ \\\\ ]]; then
line=${line//\\\\/\\}
fi
results=`echo "${line}" | bash`
if [ -z "${results}" ]; then
echo "${line}"
brokecount=$((brokecount+1))
shell64=`echo "${line}" | base64`
echo "debug64: ${shell64}"
echo
fi
done <<< "$shell_parsers"
echo
echo "returning nothing: ${brokecount}"
echo "total parsers: ${shell_parsers_total}"