#!/usr/bin/perl ########################################################################## # Author : Diode # # Completed : 01/29/00 # # Reason : I don't like web surfing. # # Questions : diode@whereipretendtowork.com # # Comments : idontwanttohear@them.com # ########################################################################## use IO::Socket; $ENV{'PATH'} = '/bin:/usr/bin'; $host = "www.attrition.org"; $page = "/news/index.html"; $kdepath = $ENV{HOME}."/.kde/share/apps/kdisknav/Attrition"; $EOL = "\015\012"; $BLANK = $EOL x 2; #Do we need to delete any old entries? opendir(LOCATION, "$kdepath"); @old = readdir(LOCATION); @dirlist = sort @old; closedir(LOCATION); chdir $kdepath; for($x=0; $x<=$#dirlist; $x++){ chomp($dirlist[$x]); next if ($dirlist[$x] =~ /^\./); chomp($dirlist[$x]); unlink($dirlist[$x]); } #Spank little johny $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => "$host", PeerPort => "http(80)", ); unless ($remote) { die "Can't connect to $host" } $remote->autoflush(1); print $remote "GET $page" . $BLANK; @results = <$remote>; close $remote; for($i=0; $i<=$#results; $i++){ if($results[$i] =~ /a href/){ push @new, "$results[$i]"; } } for($j=0; $j<=$#new; $j++){ $new[$j] =~ s///g; $new[$j] =~ s/ATTRITION News\.//g; $new[$j] =~ s///g; $new[$j] =~ s///g; $new[$j] =~ s///g; $new[$j] =~ s///g; $new[$j] =~ s///g; $new[$j] =~ s///g; $new[$j] =~ s/-.*//g; $new[$j] =~ s//%%/g; $new[$j] =~ s/\s//i; $new[$j] =~ s/\s/%%/i; $new[$j] =~ s/\s/%%/i; $new[$j] =~ s/^%%//i; push @clean, "$new[$j]"; } for($p=0; $p<=$#clean; $p++){ if ($clean[$p] =~ /orghttp/){ $clean[$p] =~ s/http:\/\/www\.attrition\.org//g; } ($when, $what, $where, $ttitle) = split(/%%/, $clean[$p]); next unless ($ttitle); # $ttitle =~ s/[\s|\t]//g; $newtitle = $when . " " . $ttitle; $mypath = $kdepath."/".$newtitle."\n"; open(KDEFILE, ">$mypath") || die "Can't open $mypath\n"; print KDEFILE "# KDE Config File\n"; print KDEFILE "[KDE Desktop Entry]\n"; print KDEFILE "URL=$where\n"; print KDEFILE "Icon=www.xpm\n"; print KDEFILE "MiniIcon=www.xpm\n"; print KDEFILE "Type=Link\n"; close(KDEFILE); }