RSS Feeds for the Forum
Well, it took a fair bit of programming but I've managed to create RSS feeds for every forum of the main Murga forum -- even for the "View Posts Since Last Visit" link! The Latest Posts one doesn't actually query the forum every time you click on it, it is updated every hour by cron, so really it's latest-posts-as-of-45mins-past-the-hour, still pretty cool though. Oh yeah, these ones filter off all sticky threads too :)
Beginner's
Users
How Tos
Bugs
Additional Software
Cutting Edge
Hardware
Puppy Derivatives
Puppy Projects
Announcements
Puppy Power
Suggestions
Misc
Español
Deutsch
Francais
Truly off-topic conversations
Latest Posts
For anyone interested I programmed all this myself using 2 PHP libraries -- an HTML parser and a Feed creator. So all I needed to program was the following fancy function :)
include("feedcreator.class.php");
include("html_dom_parser.php");
function forum_scrape($url, $title, $description, $filename) {
//PARSER LIBRARY STUFF
$dom = file_get_dom($url);
//RSS LIBRARY STUFF
$rss = new UniversalFeedCreator();
$rss->useCached();
$rss->title = 'Puppy - '.$title;
$rss->description = $description;
$rss->link = "http://www.murga-linux.com/puppy";
$rss->feedURL = 'http://74.54.199.50/~whodo/feed_creator/forum_feeds/'.$filename;
foreach($dom->find('table.forumline tr') as $table_row){
//Filter off irrelvant table rows
if (! $table_row->find('td span.topictitle') ) continue;
//Filter off sticky threads
if ( eregi('sticky', $table_row->find('td img', 0)->src) ) continue;
if ( eregi('announce', $table_row->find('td img', 0)->src) ) continue;
//Fill her up
$item = new FeedItem();
$item->title = trim($table_row->find('span.topictitle a', 0)->plaintext);
$item->link = 'http://www.murga-linux.com/puppy/'.trim($table_row->find('span.topictitle a', 0)->href);
$item->description = trim($table_row->find('td span.gensmall', 0)->plaintext);
//item->descriptionTruncSize = 500;
$item->descriptionHtmlSyndicated = true;
$rss->addItem($item);
}
// valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1, MBOX, OPML, ATOM0.3, HTML, JS
$rss->saveFeed("RSS2.0", "feed_creator/forum_feeds/$filename", FALSE);
// clean up memory
$dom->clear();
unset($dom);
}
- tombh's blog
- Login or register to post comments