-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmacosinit.sh
More file actions
101 lines (80 loc) · 3.09 KB
/
macosinit.sh
File metadata and controls
101 lines (80 loc) · 3.09 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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/sh
# NOTICE: Requires chmod +x ./macosinit.sh
# Requesting if want schedule
echo "Welcome to twitterscraper.py setup.\n\n"
# writing config to config.cfg
echo "twitterscraper.py requires a twitter account username and password to scrape data. If you do not provide these now, you must manually create and enter them in a config.cfg later."
echo "Do you wish to provide these now? (y/n)\n"
read BOT_NOW
COUNT=1
while [ $BOT_NOW != "y" ] && [ $BOT_NOW != "n" ]; do
echo "Only 'y' or 'n' are accepted responses. Please try again."
read BOT_NOW
done
if [ $BOT_NOW == "y" ]; then
echo "\nPlease provide the twitter bot username. Ensure this is correct, there will be no re-try."
read BOT_USERNAME
echo "\nPlease provide the twitter bot password. Ensure this is correct, there will be no re-try."
read BOT_PASSWORD
echo "\nWriting details to config.cfg\n"
echo "[$COUNT]" > config.cfg
COUNT=$((COUNT+1)) # increment count by 1
echo "botusername = $BOT_USERNAME" >> config.cfg
echo "botpassword = $BOT_PASSWORD" >> config.cfg
fi
echo "Do you wish to set up multiple bots now in order to use distributedtwitterscraper.py (y/n)?"
read MULTI
while [ $MULTI != "y" ] && [ $MULTI != "n" ]; do
echo "Only 'y' or 'n' are accepted responses. Please try again."
read MULTI
done
if [ $MULTI == "y" ]; then
MULTI=true
else
MULTI=false
fi
while $MULTI; do
echo "\nPlease provide the twitter bot username. Ensure this is correct, there will be no re-try."
read BOT_USERNAME
echo "\nPlease provide the twitter bot password. Ensure this is correct, there will be no re-try."
read BOT_PASSWORD
echo "\nWriting details to config.cfg\n"
echo "\n" >> config.cfg
echo "[$COUNT]" >> config.cfg
COUNT=$((COUNT+1)) # increment count by 1
echo "botusername = $BOT_USERNAME" >> config.cfg
echo "botpassword = $BOT_PASSWORD" >> config.cfg
echo "Bot added to config.cfg - do you wish to create another? (y/n) "
read MULTI
while [ $MULTI != "y" ] && [ $MULTI != "n" ]; do
echo "Only 'y' or 'n' are accepted responses. Please try again."
read MULTI
done
if [ $MULTI == "y" ]; then
MULTI=true
else
MULTI=false
fi
done
# setting up dependencies
echo "Setting up python virtual environment and downloading Python requirements: playwright (dep: Nightly firefox) and pandas."
python3 -m venv ./ # set up new venv for python installs, ~1 min
source bin/activate # activate venv
pip install -r requirements.txt # download all files ~ 100Mb minus nltk.download()
playwright install firefox # downloads only firefox browser ~85mb
# Requesting if want run script now
echo "\n\nSetup complete. Do you want to run the python script now?(y/n)"
read LAUNCH
while [ $LAUNCH != "y" ] && [ $LAUNCH != "n" ]; do
echo "Only 'y' or 'n' are accepted responses. Please try again."
read LAUNCH
done
if [ $LAUNCH == "y" ]; then
LAUNCH=true
else
LAUNCH=false
fi
if $LAUNCH; then
python3 twitterscraper.py
fi
echo "Setup completed. Run script manually with $ python3 twitterscraper.py while in venv."