NAME
XML::RSS::FOXSports - An XML::RSS::Parser subclass for parsing Foxsports.com RSS feeds.
SYNOPSIS
USING XML::RSS::Parser VERSION 2.15
#!/usr/bin/perl -w
use strict;
use XML::RSS::FOXSports;
my $fsp = new XML::RSS::FOXSports;
my $soc_feed = $fsp->parse_soccer;
my $mlb_feed = $fsp->parse_mlb;
print "item count: ", $soc_feed->item_count()."\n\n";
foreach my $i ( $soc_feed->items ) {
map { print $_->name.": ".$_->value."\n" } $i->children;
print "\n";
}
#-- retrieve values for attribution
my $img = $mlb_feed->image();
print $img->children('title')->value, "\n";
print $img->children('url')->value, "\n";
print $img->children('link')->value, "\n";
print $img->children('width')->value, "\n";
print $img->children('height')->value,"\n";
my @leagues = $fsp->get_available_leagues
my @teams = $fsp->get_available_teams
USING XML::RSS::Parser VERSION 4.0
#!/usr/bin/perl -w
use strict;
use XML::RSS::FOXSports;
my $fsp = XML::RSS::FOXSports->new;
my $glxy_feed = $fsp->parse_mls_team('galaxy');
#-- output some values
my $glxy_title = $glxy_feed->query('/channel/title');
print $glxy_title->text_content,"\n";
print $glxy_feed->item_count, "\n";
foreach my $i ( $glxy_feed->query('//item') ) {
my $node = $i->query('title');
print ' ', $node->text_content, "\n";
}
ABSTRACT
XML::RSS::FOXSports is an XML::RSS::Parser subclass providing an object oriented interface to FOXSports.com RSS 2.0 feeds.
DESCRIPTION
XML::RSS::FOXSports provides retrieval and parsing functionality for FOXSports.com's RSS 2.0 feeds. It is a subclass of Timothy Appnel's XML::RSS::Parser. This module has an object oriented interface and creates a hidden HTTP client with LWP::UserAgent for feed retrieval. Each XML::RSS::FOXSports parser object encapsulates its own XML::RSS::FOXSports::Utils object unless the NoUtil
option is passed to the constructor method.
The naming conventions used in this module (e.g., method and team names) have followed those from FOXSports.com's website as closely as possible. However, some method and team names have additional alternatives or mnemonics where it seems intuitive.
Excepting the team parsing methods, all parsing methods name the feed they are retrieving. For example the parse_soccer and parse_mlb methods parse the Soccer and MLB feeds respectively.
CAVEATS
XML::RSS::Parser VERSIONS
This module was originally written for and used with XML::RSS::Parser Version 2.15. It has been modified for compatibility with XML::RSS::Parser Version 4.0 and has worked successfully with both versions. However, be aware that it was intended for use with Version 2.15 and testing with version 4.0 has been relatively limited.
FOXSPORTS.COM RSS FEED USAGE
FOXSports.com requires attribution for use of their content.
From FOXSports.com website: "The feeds are free of charge to use for individuals and non-profit organizations for non-commercial use. Attribution (included in each feed) is required."
Please see the FOXSports.com RSS website for terms of use: http://msn.foxsports.com/story/2005035
METHODS
The following methods are provided in this package in addition to those inherited from XML::RSS::Parser.
All parse_* methods retrieve the named RSS feed over HTTP, parse the feed, and return a XML::RSS::Parser::Feed object. A die is thrown if a parse error occurs.
- new([NoUtil => 1])
-
Constructor method. The folowing options are allowed.
- * NoUtil
-
Prevents creation of the XML::RSS::FOXSports::Utils object. Access to its methods via a XML::RSS::FOXSports parser object will not be available. See Below.
HEADLINE FEEDS
These methods retrieve and parse the named RSS headline feed data.
- parse_soccer
- parse_mlb
-
parse_baseball is an equivalant mnemonic
- parse_headlines
- parse_nfl
-
parse_football is an equivalant mnemonic
- parse_ncaa_fb
-
parse_college_football is an equivalant mnemonic
- parse_nba
-
parse_basketball is an equivalant mnemonic
- parse_nhl
-
parse_hockey is an equivalant mnemonic
- parse_ncaa_bk
-
parse_college_basketball is an equivalant mnemonic
- parse_nascar
- parse_golf
- parse_tennis
- parse_horseracing
- parse_wnba
VIDEO FEED PARSING METHODS
These methods retrieve and parse the named RSS video feed data.
- parse_most_watched_video
- parse_top_news_video
- parse_mlb_video
-
parse_baseball_video is an equivalant mnemonic
- parse_nfl_video
-
parse_football_video is an equivalant mnemonic
- parse_ncaa_fb_video
-
parse_college_football_video is an equivalant mnemonic
- parse_nba_video
-
parse_basketball_video is an equivalant mnemonic
- parse_nhl_video
-
parse_hockey_video is an equivalant mnemonic
- parse_ncaa_bk_video
-
parse_college_basketball_video is an equivalant mnemonic
- parse_more_video
TEAM FEED PARSING METHODS
These methods retrieve and parse the RSS feed for a given sports team. See the README file for the list of available league and team values. Also see below
- parse_team($league, $team)
-
$league can be one of MLS, SOCCER, MLB, NFL, NBA, or NHL. $team must be an existing team name within the given $league. See the README file for the complete list of available team values. Also see below.
- parse_mls_team($team)
- parse_mlb_team($team)
- parse_nfl_team($team)
- parse_nba_team($team)
- parse_nhl_team($team)
UTILITY METHODS
- http_timeout
-
Returns the current timeout value of the wrapped HTTP client requesting the RSS feed.
- http_timeout($seconds)
-
Sets the timeout value of the wrapped HTTP client requesting the RSS feed.
PROVIDED BY XML::RSS::FOXSports::Utils
These methods will not be available if the NoUtil
option is passed to the constructor method.
- get_available_feeds
-
Returns a list of all headline and video feed names this package parses
- get_available_headline_feeds
-
Returns a list of headline feed names this package parses
- get_available_video_feeds
-
Returns a list of video feed names this package parses
- get_available_leagues
-
Returns a list of league names that can be passed to the parse_team method
- get_available_teams
-
Returns a list of all team names that can be passed to the parse_team method
- get_available_leagues_teams
-
Returns a hash reference of teams names indexed by league name
- get_feed_url($feed_name)
-
Returns the url of the named feed
- get_feed_urls
-
Returns the urls for headline and video feeds
LEAGUE AND TEAM OPTIONS FOR TEAM METHODS
The following league and team options are currently provided.
Usage example: my $giants_feed = $fsp->parse_team('MLB', 'giants');
MLS
los_angeles dc_united columbus
chicago san_jose fc_dallas
real_salt_lake colorado metrostars
new_england kansas_city chivas_usa
MLB
angels astros athletics blue_jays braves
brewers cardinals cubs devil_rays diamondbacks
dodgers giants indians mariners marlins
mets nationals orioles padres phillies
pirates rangers red_sox reds rockies
royals tigers twins white_sox yankees
NFL
forty_niners bears bengals bills broncos
browns buccaneers cardinals chargers chiefs
colts cowboys dolphins eagles falcons
giants jaguars jets lions packers
panthers patriots raiders rams ravens
redskins saints seahawks steelers texans
titans vikings
NBA
sixers bobcats bucks bulls cavaliers
celtics clippers grizzlies hawks heat
hornets jazz kings knicks lakers
magic mavericks nets nuggets pacers
pistons raptors rockets spurs suns
supersonics timberwolves trail_blazers warriors wizards
NHL
avalanche blackhawks blue_jackets blues bruins
canadiens canucks capitals coyotes devils
flames flyers hurricanes islanders kings
lightning maple_leafs mighty_ducks oilers panthers
penguins predators rangers red wings sabres
senators sharks stars thrashers wild
DEPENDENCIES
XML::Parser XML::RSS::Parser 2.15 Class::XPath
SEE ALSO
XML::RSS::Parser::Element, XML::RSS::Parser::Feed, XML::SAX, XML::Elemental, Class::ErrorHandler
AUTHOR
Brian Perez <perez@cpan.org>
COPYRIGHT & LICENSE
Copyright (c) Brian Perez 2005. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 330:
Expected text after =item, not a bullet