forked from PublicaLivros/scraping-dominio-publico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·77 lines (72 loc) · 1.99 KB
/
run.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
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
feedback="init"
function execute() {
local executecommand=$1
if [[ executecommand -eq 1 ]]; then
echo "Doing web scraping of the website data..."
node ./js/scraping.js
elif [[ executecommand -eq 2 ]]; then
echo "Downloading the books using the obtained scraping..."
if [[ -e "./json/raw_data.json" ]]; then python ./python/download.py;
else echo "Oops, you didn't do the scraping!";
fi
elif [[ executecommand -eq 3 ]]; then
echo "Removing raw_data.json..."
if [[ -e "./json/raw_data.json" ]]; then
rm ./json/raw_data.json;
if [[ $? == 0 ]]; then echo "raw_data.json removed successfully!"; fi
else echo "Scraping data doesn't exist";
fi
elif [[ executecommand -eq 4 ]]; then
echo "Removing all books from booklibrary..."
if [[ -d "./booklibrary" ]]; then
rm ./booklibrary/*;
if [[ $? == 0 ]]; then echo "Books removed successfully!"; fi
else echo "There are no books saved here.";
fi
else
return 1
fi
}
function showMenu() {
echo -e "SCRAPING - PUBLIC DOMAIN:
==============================
1) NodeJS scraping for raw_data.
2) Download books from raw_data scraping.
3) Remove raw_data scraping.
4) Remove all books from "booklibrary".
help) Help about this script.
"
echo "$feedback"
echo -n "Choose: "
read -r usrinput
clear
testInput $usrinput
feedback=""
}
function testInput() {
case $1 in
1)
execute 1
;;
2)
execute 2
;;
3)
execute 3
;;
4)
execute 4
;;
help)
echo "Is it so complicated to press a button?"
;;
*)
clear
if [[ $feedback != "init" ]]; then feedback="Command not found."; fi
if [[ $feedback == "init" ]]; then feedback=""; fi
showMenu
;;
esac
}
testInput $1