Skip to content

Instantly share code, notes, and snippets.

@dlundquist
Created October 25, 2012 03:31
Show Gist options
  • Save dlundquist/3950264 to your computer and use it in GitHub Desktop.
Save dlundquist/3950264 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use LWP;
# $prerequisites->{course}->{requirement}
my $prerequisites = {};
my $ua = LWP::UserAgent->new();
my $response = $ua->get("http://www.washington.edu/students/crscat/cse.html");
die "Error: ", $response->status_line unless $response->is_success;
foreach my $line (split /^/, $response->content()) {
next unless $line =~ /^<P><B><A NAME="(cse\d{3})">(CSE \d{3}) <\/A> ([\w\s]+) \((\d+)\) <\/B><BR>(.+) Prerequisite: ([^\.]+)/;
my $short_name = $1;
my $course = $2;
my $name = $3;
my $credits = $4;
my $description = $5;
print "Code:\t$1\n";
print "Course:\t$2\n";
print "Name:\t$3\n";
print "Credits:\t$4\n";
print "Description:\t$5\n";
print "Prerequisite:\t$6\n\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment