-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowse
More file actions
executable file
·51 lines (49 loc) · 1.54 KB
/
browse
File metadata and controls
executable file
·51 lines (49 loc) · 1.54 KB
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
#!/bin/bash
cd searchit
display_help(){
echo -e "browse [webpage] [search]\n"\
"**********************************************************\n"\
"Description:\n"\
"Use the given website search function without opening the page.\n"\
"**********************************************************\n"\
"List of all availabe commands:\n\n"\
"browse [webpage] [search]\tWill search a website with [search]\n"\
"-f [\"search link\"]\tUsed for unscrapable websites by searching test and using the given link in quotes\n"\
"-l\tLists all saved websites"
}
stored_exists(){
if [[ -f stored.txt ]]; then
if [[ -n $(grep $1 stored.txt) ]]; then
return 0
fi
fi
return 1
}
case $1 in
--help)
display_help
;;
-f)
if [[ -n $2 && $2 =~ https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]+\.[a-zA-Z0-9()]+ ]]; then
python searchit.py find $2
else
echo "Please enter a url returned from a website when searching 'test'."
fi
;;
-l)
if [[ -f stored.txt ]];then
echo "This is a list of saved websites:"
cut -d" " -f1 stored.txt
else
echo "No stored websites."
fi
;;
*)
if [[ $# == 2 && $(stored_exists $1) || $1 =~ [a-zA-Z0-9@:%._\+~#=]+\.[a-zA-Z]+ ]]; then
python searchit.py $@
else
echo "You entered something wrong."
display_help
fi
;;
esac