Gossamer Forum
Home : Products : Links 2.0 : Customization :

Trying to retrieve News based on some instructions by Widgetz

Quote Reply
Trying to retrieve News based on some instructions by Widgetz
This is what i did:#!/usr/local/bin/perl

require "admin/links.cfg";
require "$db_script_path/links.def";
require "$db_script_path/db_utils.pl";
require "$db_script_path/Template.pm";

use lib '/usr/libdata/perl5/site_perl';
use LWP::Simple;
print "Content-type: text/html\n\n";
$news = get qq!http://newsclicker.com/wire/?18202&501/!;
while ($news =~ m#<a href="([^"]+)">([^<]+)</a>#sog) {
($url, $title) = ($1, $2);

print &load_template ('news.html', {
url => $url,
title => $title
});
}

but the script is creating one news.html page for each headline instead of putting all of them into one single page.

What's for finishing this script?

For a better idea, access this test page:

http://budosearch.cjb.net/links/news2.cgi


Thanks!

Dudu

Quote Reply
Re: Trying to retrieve News based on some instructions by Widgetz In reply to
Code:
while ($news =~ m#<a href="([^"]+)">([^<]+)</a>#sog) {
($url, $title) = ($1, $2);
$articles .= &load_template ('news_item.html', {
url => $url,
title => $title
});
}

the make a template called "news_item.html" and have the content be..

<a href="<%url%>"><%title%></a>

then at the end of the script.. put

Code:
print &load_template ('news.html', {
aricles => $articles
});

and in the template.. put <%articles%>

jerry