I'm trying to write a script that will open a socket connection to a
website and return a gif. I got it working to the point where and send
the request and receive the response, I was able to remove the HTTP
headers the only problem is that the GIF wont display properly. I
downloaded the gif via my browser and compared the files and the are
identical. Does it have something to do with the file to being binary
or something because I tried to set the mode to raw and that had no
effect. Any help would be appreciated. Code Below:
#!/usr/bin/perl -w
use strict;
use IO::Socket::INET;
use open IN => ":raw", OUT => ":raw";
#Local variable declarations
my $socket;
my $request;
my $symbol;
my $chart;
my $time = 8;
my $freq = 1;
foreach $symbol (@ARGV)
{
#request string
$request = "GET
/bc3/quickchart/chart.asp?symb=".$symbol."&compidx=aaaaa%3A0&ma=0&maval=
9&uf=0&lf=1&lf2=0&lf3=0&";
$request = $request."&size=2&state=8&sid=1414&style=320";
$request =
$request."&time=".$time."&freq=".$freq."&nosettings=1&rand=300&mocktick=
1&rand=1796 HTTP/1.0\n\n";
#open socket and out file
$socket = IO::Socket::INET->new("chart.bigcharts.com:80");
open(CHARTFILE, ">".$symbol.".gif");
# send the request
print $socket $request;
#debug print
print $request;
#read from the socket and stuff into the chart scalar
while (<$socket>)
{
$chart = $chart.$_;
}
#take off the header
$chart = substr($chart, index($chart, "private"));
$chart = substr($chart, index($chart, "\n"));
$chart = substr($chart, 2);
#print the gif to a local file
print CHARTFILE $chart;
#close the socket
close($socket);
# reset the chart scalar
$chart = "";
}
exit;
Thanks,
Shawn Bower
Advent Designs
[EMAIL PROTECTED]
TEL: 607-937-5081
FAX: 607-9375081
www.advws.net