David,

Thanks for the time you took! I've had a few moments to add the HTML::TableExtract module to my ActiveStates version of perl.

I tried running your program and got no response (I both used the entries you gave and customized the zipcode and service to my area).

I have to admit, I don't know much about the various features of perl you are using. I looked up cookie_jar, however and, according to the manual (http://www.perldoc.com/perl5.8.0/lib/LWP/UserAgent.html) you have to define the methods "extract_cookies($request)" and "add_cookie_header($request)". Neither of which are in your program. Is it possible that the cookie stuff is not working correctly? Where would I find out how to define these methods?

Thanks,

William Fishburne

On Fri, 27 Jun 2003 09:52:40 -0400 (EDT), David A. Desrosiers <[EMAIL PROTECTED]> wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


I'll post it when I get it, but don't hold your breath.  My wife decided
she'd rather buy a Sunday paper than let me play with figuring out how to
do this...  That means I can eke about less than an hour a week to look at
it, which, simply, doesn't work.  It isn't enough time at one sitting.
By the time I figure out where I am and what to do next, it is time to
stop...

Let me give you a head start.


        You'll need to figure out how to dress this up to split the fields
where I've joined them with with some commas. It should be an easy jump from
there to sticking in the proper HTML tags you need, dropping this to a local
file, and using Plucker to convert that, or you could do it all inline. If I
get some "Spare Time(tm)", I might spend a bit more effort and fix this up.
It took me about 12 minutes to write, once I figured out where the tvguide
listings were buried in the table:

## CUT HERE ##
        #################################################################
        # tvslurp.pl
        #
        # A perl script to fetch TV Guide listings for a given zipcode
        # and subscriber type (cable, dish, antenna)
        #
        # Copyright 1999-2003 David A. Desrosiers. All Rights Reserved.
        #
        # Permission to use, copy, modify, and distribute this software
        # is hereby granted without fee, provided that the copyright
        # notice and permission notice are not removed.
        #
        # -dad 6/20/2003
#################################################################
        use strict;
        use LWP::UserAgent;
        use HTTP::Cookies;
        use HTML::TableExtract;

        # Define your service preference here
        # Cable                 = 1
        # Sattelite Dish        = 2
        # Broadcast/Antenna     = 3

        my $service     = '1';
        my $zip         = '02891';
        $service = $service == 1 ? 'Cable'
                 : $service == 2 ? 'Satellite' : 'Broadcast';

my $cookiefile = 'tvguide.cookies';

        my $ua          = 'Mozilla/4.0 (Windows NT 5.0)';
        my $browser     = LWP::UserAgent->new(
                                agent           => "$ua",
                                env_proxy       => 1,
                                timeout         => 30,
        );

        $browser->cookie_jar(HTTP::Cookies->new(
                                'file'           => $cookiefile,
                                'ignore_discard' => 1,
                                'autosave'       => 1,));

        my $url         = 'http://tvguide.com/listings/setup/';
        $url            .= "Localize${service}.asp?I=&ZipCode=${zip}&url=";

        print "Fetching $service TVGuide listings for zipcode $zip\n";
        my $response    = $browser->get($url);
        my $content     = $response->content;

        my $te = new HTML::TableExtract(depth => 3,
                                        count => 4);
        $te->parse($content);

        foreach my $table ($te->tables) {
                foreach my $row ($te->rows($table)) {
                        print join(',', @$row), "\n";
                }
        }
__END__
## CUT HERE ##


d.


perldoc -qa.j | perl -lpe '($_)=m("(.*)")'

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE+/EwukRQERnB1rkoRAiRdAJ9okzvQDk1dzdyL7H5fWQFwQkwF0wCfZpfJ
+/6PZrWpZcByL85LsKXsJ8M=
=Sd7J
-----END PGP SIGNATURE-----
_______________________________________________
plucker-list mailing list
[EMAIL PROTECTED]
http://lists.rubberchicken.org/mailman/listinfo/plucker-list






_______________________________________________ plucker-list mailing list [EMAIL PROTECTED] http://lists.rubberchicken.org/mailman/listinfo/plucker-list

Reply via email to