-
Notifications
You must be signed in to change notification settings - Fork 1
/
init
executable file
·32 lines (28 loc) · 1.24 KB
/
init
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
#!/usr/bin/env bash
mkdir data
cd data && wget --recursive -np -l 800 'https://oa.cc.iitk.ac.in/Oa/Jsp/OAServices/IITk_SrchStudRoll.jsp?selstudrol=1&selstuddep=&selstudnam='
#copy files to data.
for i in data/oa.cc.iitk.ac.in/Oa/Jsp/OAServices/*numtxt*
do
cp $i data/
done
#rm -rf data/oa.cc.iitk.ac.in
cd data
ls | while read file; do
new=$( echo $file | cut -d "=" -f 3 | cut -d "&" -f 1 )
new="$new"
mv "$file" "$new"
done
for file in *
do
rollno=$(cat $file | grep -iPA1 "<b>Roll no: </b>" | sed "s/[[:space:]]\+/ /g" | tail -n 1)
name=$(cat $file | grep -iPA1 "<b>Name: </b>" | sed "s/[[:space:]]\+/ /g" | tail -n 1)
program=$(cat $file | grep -iPA1 "<b>Program: </b>" | sed "s/[[:space:]]\+/ /g" | tail -n 1)
dept=$(cat $file | grep -iPA1 "<b>Department: </b>" | sed "s/[[:space:]]\+/ /g" | tail -n 1)
hostel=$(cat $file | grep -iPA1 "<b>Hostel Info: </b>" | sed "s/[[:space:]]\+/ /g" | tail -n 1)
username=$(cat $file | grep -iPo "mailto:[a-zA-z]+@iitk.ac.in" | cut -d ":" -f2 | cut -d "@" -f1)
gender=$(cat $file | grep -iPA1 "<b> Gender:</b>" | sed "s/[[:space:]]\+/ /g" | tail -n 1)
output="$rollno | $name | $program | $dept | $hostel | $username | $gender"
echo $output > $file.dat
rm -f $file
done