I'm trying to do some automation. One thing I am planning to do is to save the results of a pricegrabber.com search so I can have some sort of reference. Here's the code I am using say for searching "streetpilot iii":
---------------------------------
$searchterm = "streetpilot iii";
$function = "GET";
$workFile = "/search_gen.php";
$versionInfo = "HTTP/1.0\n\n";
$workString = "?f";
$workString .= "&topcat_search=1";
$workString .= "&form_keyword=$searchterm";
$workString .= "&topcat_id=\"\"";
$workString .= "&ut=d843c947c3f6c07c";
$request = "$function $workFile$workString $versionInfo";
print "\n\n<P>REQUEST = $request<P>\n\n"; # Used for testing!
use IO::Socket;
$socket = IO::Socket::INET->new(PeerAddr => "www.pricegrabber.com",
PeerPort => 80,
Proto => "tcp",
Type => SOCK_STREAM,
Timeout => 20)
or $the_socket_msg = "COULDN'T CONNECT TO WWW.PRICEGRABBER.COM: $@\n";
if ($the_socket_msg eq "") {
print $socket "$request";
while (<$socket>) { push (@lines, $_) }
close($socket);
print "\n\n<P>SOCKET = $socket<P>\n\n"; # Used for testing!
} else {
# If there was a socket error, then update
# the Web Store Error Log!
$the_error_msg = "ERROR";
print "\n\nTHERE WAS A SOCKET ERROR<BR>\n\n"; # Used for testing!
}
foreach $line (@lines) {
print "\n\nLINE = $line<BR>\n\n"; # Used for testing!
}
----------------------------------------
Here's the result I'm getting when I try running it:
<P>REQUEST = GET /search_gen.php?f&topcat_search=1&form_keyword=streetpilot iii&topcat_id=""&ut=d843c947c3f6c07c HTTP/1.0
<P>
<P>SOCKET = IO::Socket::INET=GLOB(0x81edc0c)<P>
LINE = HTTP/1.1 400 Bad Request
<BR>
LINE = Date: Tue, 05 Aug 2003 23:16:25 GMT
<BR>
LINE = Server: Apache/1.3.27 (Unix) (Red-Hat/Linux) mod_gzip/1.3.26.1a PHP/4.3.1 mod_ssl/2.8.12 OpenSSL/0.9.6b
<BR>
LINE = Connection: close
<BR>
LINE = Content-Type: text/html; charset=iso-8859-1
<BR>
LINE =
<BR>
LINE = <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<BR>
LINE = <HTML><HEAD>
<BR>
LINE = <TITLE>400 Bad Request</TITLE>
<BR>
LINE = </HEAD><BODY>
<BR>
LINE = <H1>Bad Request</H1>
<BR>
LINE = Your browser sent a request that this server could not understand.<P>
<BR>
LINE = The request line contained invalid characters following the protocol string.<P>
<BR>
LINE = <P>
<BR>
LINE = <HR>
<BR>
LINE = <ADDRESS>Apache/1.3.27 Server at default.pricegrabber.com Port 80</ADDRESS>
<BR>
LINE = </BODY></HTML>
<BR>
------------------------------------------------------
When I try running the same via a browser:
[pricegrabber.com...] iii&topcat_id=""&ut=d843c947c3f6c07c HTTP/1.0
It works and gives me the output.
Am I missing something?
Thanks!