Perl script to suck courses files
| -UncategorizedBack when I didn’t have a Download as Archive in the courses system, I
used this script to suck all the files.
#!/usr/bin/perl use English; $SESSIONID = $ARGV[0]; open INDEX, "curl -b PHPSESSID=$SESSIONID 'http://courses.ateneo.edu/submit/index.php?project_id=$ARGV[1]' |"; while (($s =) && ($s !~ /select name="login"/)) { } my @logins; my @lnames; my @fnames; my $i = 0; while ( =~ /option value="(\w+)"> (.+?), (.+?)) && ($s !~ /smaller/)) { } my $login; my $timestamp; while ($s = ) { if ($s =~ / (\w+?); # skip name ; # skip email ; # skip first part; if ( =~ /^\s*(.+?)\s*$/) { $timestamp = $1; } ; # skip ; # skip ; # skip } elsif ($s =~ /nbsp/) { # $s nbsp; ; # td valign = top ; # files while (($s = ) && ($s =~ /index\.php\?project_id=(\d+)\&login=(\w+)\&file=(.+?)\"/)) { mkdir $1; mkdir "$1/$2"; system "curl -b PHPSESSID=$SESSIONID 'http://courses.ateneo.edu/submit/index.php?project_id=$1&login=$2&file=$3' -o $1/$2/$3"; } } elsif ($s =~ /html/) { close INDEX; exit; } }
You can comment with Disqus or you can e-mail me at sacha@sachachua.com.