Posted by
jlittle, 13:04, 17th February 2003:
Hi, any experts at perl able to help here?
www.perl.com/pub/a/2001/11/15/creatingrs...
Apparently shows how to create your own RSS file for the BBC News headlines - however, it doesn't seem to work.
Ideally, what I want, is to do something like that, but for the following page
cpfc.org/news/docs/jsnews.txt
Is perl the best way to go, or could php do the same thing quite easily? I'm no coding expert, so any help would be great.
Cheers
James
Posted by
jlittle, 15:13, 17th February 2003:
anyone? :(
Posted by
Emperor, 15:43, 17th February 2003:
jlittle: I'd recommend using PHP (although Perl should be fine). If you want to use PHP then phpxmlclasses have a good RSS parser (and the fase4 parser works fine with no bother setting it up):
development.gurusnetwork.com/links/175/
If you still want to use Perl then have a look at these links:
development.gurusnetwork.com/links/170/
and if there aren't many Perl people around here then throw your question in here:
development.gurusnetwork.com/discussion/...
as Piper and others know their stuff there ;)
Posted by
jlittle, 15:46, 17th February 2003:
cheers, but those php things are not what I am after, they put the RSS onto a php page, however I want to convert it the other way round.
Posted by
Emperor, 16:00, 17th February 2003:
jlittle: Ahh sorry I was rushing and didn't take time to read through the site - interesting stuff. You are actually scraping the news from the BBC site into an RSS feed. Doable in PHP I'm sure although I can't imagine there is a huge demand for it.
OK 2 sugestions:
1. Have a nose around to see if someone else isn't already doing this (why do the work twice eh?).
2. Post a note in the Gurus Network forum and I'll drop someone a line to come and have a look at your code (if there is anyone around).
and I'll have a look around for a better fix to the problem ;)
Posted by
Emperor, 16:43, 17th February 2003:
If you just want the BBC's news then this will be coming soon so I'd just wait (as scraping another site seems a lot of bother):
www.bbc.co.uk/syndication/
Unofficial example feeds can already be found like:
www.bbc.co.uk/syndication/feeds/news/ukf...
www.bbc.co.uk/syndication/feeds/news/ukf...
if you want more than that then PHP isn't a problem either it is just a matter of looking at the page and seeing how to split it up using things like regular expressions. Its your call.
Posted by
Emperor, 16:53, 17th February 2003:
jlittle: You'd have to show us your implementation of the Perl script but the issue with scraping is that you have to make sure that your script is set to indetify the right places to split the page's contents. That script is from 2001 and the BBC site has recently been redesigned so you will have to change the script to reflect this - have a look at the source of the page here:
news.bbc.co.uk
and adjust things accordingly.
Also do you have the various Perl modules available?
Posted by
jlittle, 17:04, 17th February 2003:
Yeah, I have all the mod's installed.
www.exwebjunkie.com/testperl.txt is what I have so far, but it's producing the RSS file without any links.
Posted by
cal, 17:55, 17th February 2003:
well, your script is quite wildly wrong for a start.
you're link finding code might be correct, but the title finder is looking for headlines in bold tags, and your feed doesn't have <b> tags round the headline you wanted, but rather has:
<a href="/url" target="_blank">headline</a>
anyway, since your feed is dead simple, you can just regexp it:
while($content =~ /<a href="/(.*?)">(.*?)</a>/ig){
$rss->add_item( title => $2, link => $1);
}
Posted by
jlittle, 21:48, 17th February 2003:
Full perl here :
www.exwebjunkie.com/bbstest.txt
getting this error :
Bareword found where operator expected at bbstest.pl line 42, near "/
(.*?)(.*?)>
Posted by
jlittle, 21:55, 17th February 2003:
also tried it like this
my ($tag, $headline, $url);
while($content =~ /
(.*$headline)//ig){
$rss->add_item( title => $url, link => $headline);
}
$rss->save("testnews.rss");
Posted by
jlittle, 21:56, 17th February 2003:
while($content =~ /
(.*$headline)//ig){
even..
Posted by
jlittle, 21:56, 17th February 2003:
argh, silly board
Posted by
jlittle, 21:59, 17th February 2003:
aha, got it working
www.exwebjunkie.com/bbstest.txt
Posted by
cal, 09:09, 18th February 2003:
oops - my bad
<\/a> , not </a>
and if you mess up a message, just edit it rtaher than posting a sequence of four. the board accepts html, so if you want to actually display tags then use < and >