$url .= "Localize${service}.asp?I=&ZipCode=${zip}&url=";
needs to be
$url .= "Localize${service}.asp?I=-100007&ZipCode=${zip}&url=";
^^^^^^^I think this is because I live near two major cities and I'm looking at air broadcast service that can come for either municipality (I think that in addition, DirectTV has different "local listings" then cable)...so beware, your mileage may vary. Once I did this, it turns out that I pull the TV listings for the current time plus two hours...
I've saved off the "content" returned by the script below so that I can figure out how to pull back just the hour range that interests me and it looks like a POST message to a form. In addition, it looks like the calls to find the details on a given show are invocations of a javascript that just builds an URL.
I've also done a little bit of thinking about how the HTML files should look when all is done. I'm thinking that one file should just have the times (on the half-hour) in a column.
Clicking on a time would take you to a page with the channel number followed by the show at that time. The time slot would be the title of the page.
Clicking on the show would take you to a description of that show.
Anyway, I'm writing this down so I don't forget it as well as to evoke some comment...
William Fishburne
On Fri, 27 Jun 2003 13:54:51 -0400, William Fishburne <[EMAIL PROTECTED]> wrote:
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
_______________________________________________ plucker-list mailing list [EMAIL PROTECTED] http://lists.rubberchicken.org/mailman/listinfo/plucker-list

