[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-WebCGI] Are There Better ways to do this.



I want to extract stock quotes into a file so I can move this list into some
other document or speadsheet with cut or paste.  This is what I have come up
with.  I picked snap.com because it gives fairly concise quotes without a
lot of background to filter out.  Is there and easier or better way to do
this?

#!perl -w
# get_s_mf  get stock and mf prices
# gets information on stocks and funds from internet and stores in a file
called prices
# d.Krystowiak 5.31.99

use LWP::Simple;

@mystocks = ("ABT","AMAT","BA","HB","LU","MCT","SYBS");

open (OUT, "> PRICES");

foreach $stock (@mystocks){
 print "\n$stock ";           # print stock abbev to monitor
 foreach  (get
"http://www.snap.com/main/finance/stock/quote/1,204,-mysnap,00.html?ticker=$
stock"){
   s/<[^>]*>//g;              # Strips html code
   @t = split('Last:');       # split web screen on last: because price
follows this
   @f = split('
',$t[1]);     # split right side on a some kind of Mac
control code to get price in $f[1]
   if ($f[1] =~ m/\d+.\d+/) { # if prices match decimal period decmal print
it
     print "$f[1]";
     print  OUT "$f[1]\n";
   }
 } # get foreach loop

} # @mystock loop for stocks I own
print  OUT "\n--------\n";   #mutal fund divider
# use same code as above to get mutual fund priceing but split separator
different

@mymf = ("TRBCX","KAUFX","BESCX","TWCUX","VFINX","FMAGX","KAUFX","NBGNX");

foreach $mf (@mymf){
 print "\n$mf ";
 foreach  (get
"http://www.snap.com/main/finance/stock/quote/1,204,-mysnap,00.html?ticker=$
mf"){
   s/<[^>]*>//g;
   @t = split('Net asset value:');
   @f = split('
',$t[1]);
   if ($f[1] =~ m/\d+.\d+/) {
     print "$f[1]";
     print  OUT "$f[1]\n";
   }
 } # get foreach loop

} # @mymf loop


==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org