#!/usr/local/bin/perl # # File: get_slashdot_news_wml # # # 3/13/00 - I've updated the program to add a cache flush request after 30 minutes. # prevents stale info. -- Sujal # # The link on Slashdot points to get_slashdot_news_xml... it should be wml. # # This file creates a wml page (to STDOUT) from the # slashdot.rdf file. it is based off of get_slashdot_news. # The original comments for get_slasdot_news are below, under # the ==='s. # # The output (updated every 30 minutes) is available at http://sujal.net/sd.wml. # # - Sujal Shah # 1/12/00 # =============================================================== # # File: get_slashdot_news # Mister House Slashdot # Slashdot back end for MisterHouse (or not). Checks Slashdot for news # and prints (or speaks) the result. # # Author: # David Dellanave ddn@hps.com # Version: # 1.5.1 # # Last update: # 11/14/99 # # Changes: # - I fixed everything that I broke. # # - Finally ported it from ultramode.txt to the new slashdot.rdf format # I was surprised, all it took was changing what file to grab :) # # - Added a feature where the program can create a "database" in the /tmp directory for # other instances of get_slashdot to read from. The idea was to have it be able to # as a login prorgram, without always having to go out to the net to get it. # # # Notes: # Please let me know if anything doesnt work for you. Also let me know # of any snippets I dont catch. Good notes are always welcome, # I like e-mail :) Bottom line: Have fun with it /. # # This free software is licensed under the terms of the # GNU public license. # Copyleft 1999 David Dellanave use IO::Socket; use IO::Handle; # Here you can decide if you want the program to run in database mode, for running at login and stuff. # If you just want to run the program and have it output, set this to 0 $dbmode = 0; # You can tell the script to use a proxy. If $PROXY is empty it # will not use one. By default the script takes the value of the # http_proxy environment variable by default. So if there isn't # one no proxy will be used. my $PROXY = ""; my $PROXYPORT = 0; if($ENV{http_proxy}) { $ENV{http_proxy} =~ m$http://(.*?):(.*?)/$; $PROXY = $1; $PROXYPORT = $2; } # **** This part is useless for now because slashdot.rdf contains no time info # On the next line add how many hours you need to add or subtract from EDT # to get your time. Ie: $zone = "+5" to get GMT or -5 for whatever it is ;) # Leave blank for EDT #$zone = "-1"; ######################### End of Configuration ############################ if($dbmode==1) { if(-M '/tmp/slashdata' < .1) { print "\n"; exec('cat /tmp/slashdata'); } } elsif($dbmode==0) { my($iaddr, $paddr, $port, $proto, $month, $url, @articles, $runs, $times, @time, %months, $months, $day); %months = qw(1 January 2 February 3 March 4 April 5 May 6 June 7 July 8 August 9 September 10 October 11 November 12 December); if($PROXY) { $iaddr = gethostbyname($PROXY); $port = $PROXYPORT; $url = "http://slashdot.org/slashdot.rdf"; } else { $iaddr = gethostbyname("slashdot.org"); $port = 80; $url = "/slashdot.rdf"; } $proto = getprotobyname("tcp"); $paddr = sockaddr_in($port, $iaddr); unless($dbmode==0){ open(DB, ">/tmp/slashdata"); } socket(SLASH, PF_INET, SOCK_STREAM, $proto) or die "socket: $!"; connect(SLASH, $paddr) or die "Connect error: $!"; autoflush SLASH 1; print SLASH "GET $url HTTP/1.0\r\n\r\n"; $/ = "\"; my $intro = ; print <

Slashdot Headlines

Updated every 30 min.

HEADER while() { ($title) = $_ =~ /\(.*)\<\/title\>/; #push(@articles, $link); push(@titles, $title); print "\t\t

$title

\n"; } close SLASH; print <
FOOTER }