2 # Quote.pl: retrieve stock quotes from yahoo
3 # heavily based on Slashdot.pl
5 # Author: Michael Urman <mu@zen.dhis.org>
15 my @results = &::getURL("http://quote.yahoo.com/q?s=$stock&d=v1");
17 if (!scalar @results) {
18 &::msg($::who, "i could not get a stock quote :(");
21 my $flathtml = join(" ", @results);
25 s/.*?\<tr align=right\>//;
27 s/<.*?>//g; # remove HTML stuff.
28 s/\s{2,}/ /g; # reduce excessive spaces.
29 s/^\s+//; # get rid of leading whitespace
30 s/\s+$//; # get rid of trailing whitespace
32 my $reply = $flathtml;
34 if ($reply eq "" or length($reply) > 160) {
35 $reply = "i couldn't get the quote for $stock. sorry. :(";
38 &::performStrictReply($reply);