
PaPPy
New User
May 13, 2006, 6:21 AM
Post #1 of 1
(1567 views)
|
Burning Board to RSS(i have script)
|
Can't Post
|
|
hello, this is my first post on here. i am typically a php programmer but the script i need to accomplish the task im wanting to do i have found written in perl. instead of creating everything from scratch i figured i'd just modify the code below. but its above my head. let me explain what i need done there is a forum at: http://board.bitefight.org/search.php?action=24h that displays the last 20 posts on the board. i would like to put that information into a rss feed for people to use in what ever way they see fit here is what i tried doing to get it to work
#!/usr/bin/perl ####################################################################### # Burning Board converter # Generates a RSS feed of posting from the last 24 hours. # License: public domain # Original author: Oliver Feiler <kiza@gmx.net> # # Instructions: # ============= # # Please edit contents of the variables @content and $base accordingly. # # Tested against burning board 2.0.3. Might need minor modifications # for different versions due to slightly different HTML code. ####################################################################### use Data::Dumper; use XML::LibXML; # Change URLs to the ones your forum provides. my @input = `wget -q -T 20 -O - "http://board.bitefight.org/search.php?action=24h&sid="`; my $base = "http://board.bitefight.org/"; my $foo = -1; my $title; my $date; my $link; my $guid; my $author; my $rel_date; my @DB; foreach (@input) { if (/<tr bgcolor="" id="">/) { $foo = 0; } if (($foo == 0) && /<td id="tablea" width:"80%" align="left">/) { /hilightuser=0">(.*?)<.*?boardid=\d+&sid=.*">(.*?)</; $title = "$1 ($2)"; $foo = 1; } if (($foo == 1) && /javascript:who\(\d+\)/) { /javascript:who\(\d+\)">(\d+)</; if ($1 == 1) { $title .= " ($1 reply)"; } else { $title .= " ($1 replies)"; } $foo = 2; } if (($foo == 2) && /\d{2}:\d{2}<\/font>/) { /userid=*"><?b?>?(.*?)<?\/?b?>?,? ?<.*?(\d{2}:\d{2})</; $rel_date = $1; $date = $2; $guid = $2; $foo = 3; } if (($foo == 3) && /goto=lastpost/) { /href="(.*?)&sid/; $link = $base.$1; $foo = 4; } if ($foo == 4) { my %item; $item{'title'} = $title; $item{'link'} = $link; $item{'guid'} = $guid; push(@DB,\%item); $foo = -1; } } #print Dumper(\@DB); rss(); # Taken from Wolfpaper Picture Archive site gen script. # Does not work on OpenBSD 3.5 (see http://kiza.kcore.de/journal/2004-11&item=2) sub rss { my $rssbase = $base; # Create XML my $nsrss = "http://purl.org/rss/1.0/"; my $nsrdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; my $nsdc = "http://purl.org/dc/elements/1.1/"; my($doc) = XML::LibXML::Document->new(); my($text); my($root) = $doc->createElement('RDF'); $root->setNamespace($nsrss, '', 0); $root->setNamespace($nsrdf, 'rdf', 1); $root->setNamespace($nsdc, 'dc', 0); $doc->setDocumentElement($root); $doc->setEncoding("iso-8859-1"); my($channel) = $doc->createElement('channel'); $channel->setAttribute('rdf:about', "$rssbase"); $root->appendChild($channel); $channel->appendTextChild('title', 'Hetzner Forum'); $channel->appendTextChild('link', "$rssbase"); $channel->appendTextChild('description', 'Hetzner Forum'); my($channelitems) = $doc->createElement('items'); $channel->appendChild($channelitems); my($seqitems) = $doc->createElement('rdf:Seq'); $channelitems->appendChild($seqitems); foreach (@DB) { my $rssurl = $_->{'link'}; my($li) = $doc->createElement('rdf:li'); $li->setAttribute('rdf:resource', "$rssurl"); $seqitems->appendChild($li); my($rssitem) = $doc->createElement('item'); $rssitem->setAttribute('rdf:about', "$rssurl"); $root->appendChild($rssitem); $rssitem->appendTextChild('link', "$rssurl"); $rssitem->appendTextChild('title', $_->{'title'}); $rssitem->appendTextChild('guid', $_->{'guid'}); } print $doc->serialize(1); } here is a link to the original file: http://kiza.kcore.de/software/snownews/snowscripts/extensions?file=burning_bored thanks in advance, PaPPy
|