Hi all, I have been requested to repost this message to the begginers group to be worked on there.
Hopefully someone can give me a clue about a problem I'm having. I'm using the script below to try to retrieve the web page "http://inventory.overture.com/d/searchinventory/suggestion/?term=" with a term attached at the end of it. This script has been working for months and is all of a sudden returning: "500 (Internal Server Error) Can't connect to inventory.overture.com:80 (Timeout)" NOTE: *** This script is not run from a browser but is called from a PHP page and run on a Linux box in the background. I've received the above 500 error while trying to run it directly from the command line. *** I can connect to other sites without a problem such as yahoo.com. Does anyone know why something like this might suddenly be taking place after such a long time of working flawlessly? Could it be something has been changed at the web site I'm trying to get? Thanks so much in advance. Guy Davis #!/usr/bin/perl use strict; use DBI; use LWP::UserAgent; # test to make sure they entered one or two arguments if($#ARGV != 0) { print "\nUsage: getraffic.pl research_run_id\n\n"; exit(); } # We need to subclass LWP::UserAgent in order to allow redirects on POSTS # and fix some other problems. In other words, to make it behave like a # 'real' web browser @MyAgent::ISA = qw(LWP::UserAgent); sub MyAgent::redirect_ok { my ($self,$request)=@_; # ***************************************************** # IMPORTANT: # # POSTs that get redirected __MUST__ change the request # method to GET!!!! # ***************************************************** if ($request->method eq "POST") { $request->method("GET"); } return 1; } # what client do you want to get? first variable from the command line my $test_phrase = ""; my $research_id = $ARGV[0]; my $VERBOSE = 1; my $db = DB_connect(); my ($rp_id, $rp_phrase_name); my $sql = ""; my $sth; # Getting started - actively checking for traffic $sql = "UPDATE research SET research_traffic_updated=1 WHERE research_id=$research_id"; $sth = $db->prepare( $sql ); $sth->execute() || die ( $DBI::errstr ); $sql = "SELECT rp_id, rp_phrase_name FROM researchphrase WHERE rp_research_id=$research_id AND rp_status<>2 AND rp_clicks IS NULL"; $sth = $db->prepare( $sql ); $sth->execute() || die ( $DBI::errstr ); $sth->bind_columns(undef, \($rp_id, $rp_phrase_name)); while ($sth->fetch()) { # update each phrase my $kw = $rp_phrase_name; $kw =~ s/ /+/g; gettraffic($rp_id, $rp_phrase_name, $kw); } # All done - not actively checking for traffic $sql = "UPDATE research SET research_traffic_updated=0 WHERE research_id=$research_id"; $sth = $db->prepare( $sql ); $sth->execute() || die ( $DBI::errstr ); $sth->finish(); # now disconnect from the database $db->disconnect(); sub gettraffic { my ($rp_id, $rp_phrase_name, $keyword) = @_; my $traffic=0; my $url = "http://inventory.overture.com/d/searchinventory/suggestion/?term=" . $keyword; my $ua = new MyAgent; my $agent = 'Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)'; ## Set some User Agent properties. $ua->agent($agent); $ua->timeout(15); ## Convert the URL into a url object (with a couple methods we can use). my $u = new URI::URL( $url ); ## Fetch the web page. my $req = HTTP::Request->new(GET=>$u->as_string); my $res = $ua->request($req); my $resstring = $res->as_string; print "URL: $url\n" if ($VERBOSE); print "$resstring\n" if ($VERBOSE); # Check the outcome of the response if ($res->is_success) { my $content = $res->content; $content =~ m/.* ([0-9]+)<\/b>.*/s; my $traffic = $1; if (!$traffic) { $traffic = 0; } update_db($rp_id, $traffic); } } sub update_db { my ($rphraseid, $traffic) = @_; my $sql = "UPDATE researchphrase SET rp_clicks=$traffic WHERE rp_id=$rphraseid"; my $sth = $db->prepare( $sql ); $sth->execute() || die( $DBI::errstr ); $sth->finish(); } sub DB_connect { my $table = shift; my $db = DBI->connect("DBI:mysql:database", "username", "password", {PrintError=>0, RaiseError=>0}); return $db || "DBERROR: Could not connect to database."; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]