| 1 | # perl -w | ||
| 2 | # | ||
| 3 | # Copyright (C) 1998, Dj Padzensky <djpadz@padz.net> | ||
| 4 | # | ||
| 5 | # This program is free software; you can redistribute it and/or modify | ||
| 6 | # it under the terms of the GNU General Public License as published by | ||
| 7 | # the Free Software Foundation; either version 2 of the License, or | ||
| 8 | # (at your option) any later version. | ||
| 9 | # | ||
| 10 | # This program is distributed in the hope that it will be useful, | ||
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | # GNU General Public License for more details. | ||
| 14 | # | ||
| 15 | # You should have received a copy of the GNU General Public License | ||
| 16 | # along with this program; if not, write to the Free Software | ||
| 17 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 18 | # | ||
| 19 | |||
| 20 | package Finance::MoneyNetSymbolLookup; | ||
| 21 | require 5.000; | ||
| 22 | |||
| 23 | require Exporter; | ||
| 24 | use strict; | ||
| 25 | use vars qw($VERSION @EXPORT @ISA $URL); | ||
| 26 | |||
| 27 | use LWP::UserAgent; | ||
| 28 | use HTTP::Request::Common; | ||
| 29 | |||
| 30 | $VERSION = '0.02'; | ||
| 31 | $URL = ("http://www.moneynet.com/data/EQUIS/rawlookup/lookup.asp?NAME="); | ||
| 32 | @ISA = qw(Exporter); | ||
| 33 | @EXPORT = qw(&symbollookup); | ||
| 34 | |||
| 35 | sub symbollookup { | ||
| 36 | my $search = $_[0]; | ||
| 37 | my($srch,$ua,$url,$sym,$name,$type,@qr); | ||
| 38 | $url = $URL.$search; | ||
| 39 | foreach (split('\r?\n',LWP::UserAgent->new->request(GET $url)->content)) { | ||
| 40 | if (/^Symbol:(.*)/) { | ||
| 41 | ($sym,$name,$type) = split(',',$1); | ||
| 42 | push(@qr,[$sym,$name,$type]) if $type ne "TYPE"; | ||
| 43 | } | ||
| 44 | } | ||
| 45 | return wantarray() ? @qr : \@qr; | ||
| 46 | } | ||
| 47 | |||
| 48 | __END__ |