Posted: Wed May 09, 2007 9:18 pm Post subject: Help Needed prasing RSS
Hi all,
I am working on a new weather command using MSN Weather. So far I know how to get access to the rss feed however I am having trouble prasing it using XML::RSSLite
Here is what i have got working so far
Code:
sub weather {
my ($bot,$self, $user, $name, $msg, $color) = @_;
use LWP::Simple;
if ($msg eq undef){
$self->sendMessage("You did not include a location");
}else{
my $field = {};
I am aware this just returns the xml but this is as far as I have got working so far. Also I know the code is a mess but I have done my best and would appriciate help fixing and tidying the code.
Thanks _________________ "Help us, Help you" - BotDepot
my $x = XMLin($reply);
my $f = %{@{$x->{channel}->{item}}[1]}->{description};
$f =~ s/<[^<]+>//g;
$f =~ s/°/°/g;
$f =~ s/%/%\r\n/g;
$self->sendMessage($f);
}
};
I have tested it on my computer (not through my bot) and it seems to work fine, with a slight error in showing the degrees sign (it shows a hash sign instead), but I think it should be ok via messenger.
Thanks a bunch.
I know why the degree sign isnt working, it is beacuse the code is HTML. However it can easily be fixed by entering 2 lines of code.
The first is
Code:
my $deg = decode_base64("wrA=");
This line can go somewhere near where LWP simple gets the feed from MSN. This second line then swaps the html code for the degree sign.
Code:
$f =~ s/&\#176;/$deg/ig;
This then goes before the message is sent to the user.
Once Again thanks a lot _________________ "Help us, Help you" - BotDepot