<?xml version="1.0" encoding="windows-1252"?>
<node id="14594" title="Stock Quotes" created="2000-05-24 16:39:35" updated="2005-08-12 13:02:04">
<type id="1748">
sourcecode</type>
<author id="14367">
scribe</author>
<data>
<field name="doctext">
&lt;CODE&gt;
#!/usr/bin/perl -w
# Steven Rutter &lt;scribe@ziplip.com&gt;

use IO::Socket;
use strict;

if ($#ARGV &lt; 0) { die "usage: $0 &lt;symbol&gt;\n" }

my $symbol = $ARGV[0];
my $server = 'quote.yahoo.com';
my $serverPort = '80';
my $get = "/d/quotes.cgi?s=$symbol&amp;f=sl1d1t1c1ohgv&amp;e=.csv";

my $remote = new IO::Socket::INET (
                  Proto=&gt;'tcp',
                  PeerAddr=&gt;$server,
                  PeerPort=&gt;$serverPort,
                  Reuse=&gt;1 ) or die $!;

$remote -&gt; autoflush(1);

print $remote "GET $get HTTP/1.0\n\n";

my $quote;

while ( my $raw = &lt;$remote&gt;) {

  # "USVOE.OB",2.75,"4/12/2000","4:00PM",-0.3125,3.0625,3.160000,2.65625,538100
  # symb, price, lastTrade, lastTradeTime, change, high, low, volume

  if ( $raw =~ /\"/ ) {
    $quote = $raw;
  }
}

close $remote;


$quote =~ s/\"//g;
$quote =~ s/^M//g;
chomp $quote;
my @qarray = split(/,/, $quote);

print "(( $qarray[0] $qarray[1]  $qarray[4] ) ( $qarray[7] -- $qarray[6] ) ( Vol: $qarray[8] ))\n";

&lt;/CODE&gt;</field>
<field name="codedescription">
Retrieves basic stock quotes from yahoo.&lt;br&gt;
Uses IO::Socket to connect to webserver.&lt;br&gt;
Can only retrieve one quote at a time now.&lt;br&gt;&lt;br&gt;
Sample output:&lt;br&gt;
(( ELON 51.625  -3.5625 ) ( 49 -- 56.5 ) ( Vol: 1646200 ))</field>
<field name="codecategory">
Utility / Web</field>
<field name="codeauthor">
scribe@ziplip.com</field>
</data>
</node>
