#!/usr/bin/perl -w
#
# robots.pl - Some simple code to grab the XML/RSS formatted headlines from
# the robots.net site and write them to a local text file with HTML
# formatting so they may be used as an SSI on your web page. With
# minor modifications, it will probably work with other RSS files/sites.
#
# Instructions:
# 1. Make any changes desired to the configuration section below
# 2. Make sure the permissions on this file are set so that it's executable.
# 3. Add to your crontab to be called daily or hourly as desired
# 4. Add an include to the desired web page to show the output file
#
#
# Copyright (C) 2002 by R. Steven Rainwater
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 or later.
#
# History
# Version 1.0 -- 01 Feb 2002 RSR Initial release
use strict;
use Socket;
use FileHandle;
### User configurable stuff ###
# The host name of the server and the port to use
my $rss_server = "robots.net";
my $port = 80;
# The path and filename of the RSS file
my $rss_server_path = "/rss/articles.xml";
# The path and filename where the results should be stored
my $output_file = "/var/www/html/robotnews.txt";
# A simple template for the link to the server. [URL] and [TITLE] will be
# filled in automatically
my $newslink_template = 'Headlines from [TITLE]
';
# Place any HTML that will prefix the list of news items here
my $news_prefix = '
Put robots.net headlines on your page!
'; ### Don't mess with anything below this unless you know what you're doing my $newsitem = ''; my @raw = (); my @rssfile = (); my $iaddr = inet_aton($rss_server); my $paddr = sockaddr_in($port, $iaddr); socket(SOCKET, PF_INET, SOCK_STREAM, getprotobyname('tcp')); connect(SOCKET, $paddr) || die "Unable to connect $rss_server:$port\n"; SOCKET->autoflush(1); print SOCKET "GET $rss_server_path HTTP/1.0\r\nUser-Agent: robots.net RSS retrieval tool (v1.1)\r\nHost: $rss_server:$port\n\n"; @raw = grep /\