#!/usr/bin/perl # theater_rss.pl #Accepts a Yahoo! Movies theater ID and prints # an RSS feed of currently playing movies. # Usage: theater_rss.pl # # You can find theater IDs at Yahoo! Movies # at http://movies.yahoo.com/ use strict; use XML::RSS::SimpleGen; # Grab the incoming theater ID my $tid = join(' ', @ARGV) or die "Usage: theater_rss.pl \n"; my $theater_title = "My favorite theater"; # Set the theater schedule URL my $url = "http://acid1.oa.yahoo.com/mbl/mov/tdet?tid=$tid"; # Download the schedule page my $content = get_url($url); # Find the theater name if ($content =~ m!
(.*?)
!sg) { $theater_title = $1; } # Start the RSS Feed rss_new($url, "$theater_title Schedule"); rss_language('en'); rss_webmaster('insert your email address'); rss_daily(); # Set the regular expression to find data my $regex = '.*?mid=(.*?)">(.*?).*?'; $regex .= '(.*?).*?'; # Loop through the HTML, grabbing elements while ($content =~ m!$regex!sg) { # rss_item accepts url, title, description. my $url = "http://movies.yahoo.com/shop?d=hv&cf=info&id=$1"; rss_item($url, $2, $3); } # Warn if nothing was found die "No items in this content?! {{\n$_\n}}\nAborting" unless rss_item_count(); # Save the rss file as .rss rss_save("$tid.rss"); exit;