walkingthecow has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; use WWW::Mechanize; use HTML::TokeParser; use MIME::Lite; while (1) { my $msg; my @search = ("broken hdtv","fix hdtv","does not work hdtv"); my $connection = WWW::Mechanize->new(); foreach my $term (@search) { $connection->get("http://portland.craigslist.org/"); $connection->form_number(1); $connection->field("query",$term); $connection->click(); my @link = $connection->find_all_links(url_regex => qr/(ele|zip +)\/[0-9]+/i); foreach my $link (@link) { my $tempLink=$link->url_abs; chomp $tempLink; my $check=`grep $tempLink craigslist`; if ($check eq "") { open OUTFILE,">>craigslist" or die $!; print OUTFILE $tempLink . "\n"; $msg = MIME::Lite->new( To =>'xxxxxxxxxx@vtext.com', Subject =>'CL Link', Type =>'text/plain; charset="iso-8859-1"', Data =>"There is a new link on craigslist." ); close OUTFILE; } } } if ( $msg ) { $msg->send; } sleep(300); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is there a better way to do this? I need to keep track of results...
by tilly (Archbishop) on Feb 20, 2009 at 05:26 UTC | |
|
Re: Is there a better way to do this? I need to keep track of results...
by CountZero (Bishop) on Feb 20, 2009 at 06:20 UTC | |
|
Re: Is there a better way to do this? I need to keep track of results...
by dsheroh (Monsignor) on Feb 20, 2009 at 06:39 UTC | |
|
Re: Is there a better way to do this? I need to keep track of results...
by leocharre (Priest) on Feb 20, 2009 at 14:16 UTC |