#!/usr/bin/perl# RJEYR: program to grab one year's HTML page from RJE #          website and generate RDF files from articles therein# cfb 9918use Text::Wrap;use LWP::Simple;$base = "http://www.rje.org/abstracts/abstracts/";$year=$ARGV[0];$outf=">rje$year.rdf";open(OUT,$outf) || die "Cannot open $outf for output";$page = get "$base$year";(@lines)=split "\n", $page;$lines=@lines;$artcnt=0;for($i=1;$i<=$lines;$i++){   ($url)=($lines[$i-1] =~ m!NAME="(.+?)"!ig);   if ($url =~ /html$/) {        ($str) = get "$base$year/$url";         $str =~ s/\n/ /g;        $str =~ s/&amp;/&/g;        $str =~ s/&ccedil;/c/g;        $str =~ s/&ouml;/o/g;        $str =~ s/&auml;/a/g;        $str =~ s/&uuml;/u/g;        $str =~ s/&eacute;/e/g;	$str =~ s/&szlig;/Beta/g;        $str =~ s/<i>//ig;        $str =~ s/<\/i>//ig;        $str =~ s/pp:/pp./ig;        $str =~ s/Symposium in Honor of Richard E. Quandt, 1997/Symposium 1997/g;        $str =~ s/: </:</g;        $str =~ s/ No / No. /g;        ($vol,$nr)=($str =~ m!Volume:<\/strong>\s?Volume\s(.+?),.+?No.\s?(.+?)<!igs);        ($iss,$yr)=($str =~ m!Issue:</strong>(.+?) (.+?)<!ig);        ($pgref)=($str =~ m!p\s?\.(.+?)<!ig);        ($au)=($str =~ m!Authors:</strong>(.+?)<!ig);        $au =~ s/ and /,/g;        $au =~ s/, Jr./ Jr./g;        $au =~ s/,,/,/g;        (@auv)=split(",",$au);            $auv=@auv;        ($title)=($str =~ m!Title:</strong>(.+?)<!ig);         #print "\n $title \n";        ($abst)=($str =~ m!Abstract:</strong>(.+?)<!ig);        #print "\n $abst \n";           print OUT "\nTemplate-Type: ReDIF-Article 1.0\n";        foreach $auth (@auv) {                 print OUT "Author-Name: $auth\n";        }                                                print OUT "Title: $title\n";        if ($year<1984) {           print OUT "Journal: Bell Journal of Economics\n";           $ser="bellje";           }        else {           print OUT "Journal: RAND Journal of Economics\n";           $ser="randje";	   }              print OUT "Pages: $pgref\n";        print OUT "Number: $nr\nVolume: $vol\n";        print OUT "Year: $yr\nMonth: $iss";        if ($abst) {           print OUT "\nAbstract:\n";           print OUT wrap(" "," ",$abst);           }               $handl = "Handle:RePEc:rje:$ser:v:$vol:y:$yr:i:$iss:p:$pgref\n";         $handl =~ y/a-z:\-A-Z0-9//cd;        print OUT "\n$handl\n";        $artcnt++;        print " $artcnt : $url\n";        }}close(OUT);print "\n Article templates for $year : $artcnt\n\n";exit;__END__