I'm having some difficulty porting this code from perl to php...can anyone
give me a hand?

-Matt Broughton


#!/usr/bin/perl
# Quick and dirty Yahoo movie showtimes grabber

use LWP::Simple;
my $content =
get("http://movies.yahoo.com/showtimes/showtimes.html?z=florence%2C+sc&r=sim
");

my $text = '';
if ($content) {
        $content =~ s{.*<!-- movies module -->(.*)<!-- /movies
module -->.*}{$1}gism;

        my @lines = split(/\n/, $content);

        my $act = '';
        foreach (@lines) {

                next if m{^</{0,1}(table|tr|td)};
                next unless ($act || /<!-- theater -->/);
                if (/<!-- theater -->/) {
                        print "\n";
                        $act = 'theater';
                        next;
                }
                elsif (/<!-- .*? movie -->/) {
                        $act = 'movie';
                        next;
                }
                elsif (/<!-- show info -->/) {
                        $act = 'info';
                        next;
                }
                elsif (/more theaters/i) {
                        $act = 'done';
                        last;
                }

                # Strip font tags
                s{</{0,1}font.*?>}{}gi;
                # Strip HR's
                s{<hr>}{}gi;
                # Strip non-breaking spaces
                s{(&nbsp;)+}{&nbsp;}gi;
                s{<p>}{<BR>}gi;

                if ($act eq 'theater') {

                        # Remove links to Yahoo theater stuff
                        s{<a.*?>(.*?)</a>}{$1}gi;

                        # Remove Map It link in favor of a linebreak
                        s{map it}{<BR>}i;

                                    # Small-italicize anything that's not the 
theater's name
                        s{^(.*)$}{<SMALL><I>$1</I></SMALL>} unless m{<B>}i;
                }
                elsif ($act eq 'movie') {
                        s{<a href="(.*?)">}{<a
href="http://movies.yahoo.com$1";>}gi;
                }

                $text .= "$_ \n";
        }
}
else {
        $text .= '<P>Movie information is unavailable at this time.';
}

print $text;




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to