5061 comments
1899 subscribers
4801 on Twitter
Subscribe! Feed reader E-mail

Perl script to suck courses files

Back 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;
    }
}
Short URL: http://sachachua.com/blog/p/1185

Comment, share a thought, ask a question...

Please comment as you, not your organization.





 

On This Day...