Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add course scraping script. #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions courses.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# Author: Saksham Sharma
# 12th March, 2016

# Usage:
# ./courses.sh <roll_num>
roll=$1

# Send CURL request to doaa scheduler
# Keep it as close to the browser request as possible to prevent detection.
output=$(curl -s "http://172.26.142.68/examscheduler2/personal_schedule.php?rollno=$roll" -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: en-US,en;q=0.8' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.8 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Referer: http://172.26.142.68/examscheduler2/personal.html' --compressed)

# Parse the single line output with a large incomprehensible RegEx I wrote today and will forget tomorrow.
echo $output | grep -E "<tr><td>([^<]*)</td>" -o | grep -E ">([^<]+)<" -o | grep -E "[^><]*" -o