|A while back I had to re-write our intranet stock listing application that retreived stock information from the Yahoo! finance site (I didn't write the original). It was a huge cluge, and took forever to render, as each stock symbol, 401k symbol etc, was a seperate LWP request, and each request had to be parsed for the necessary data. The application began breaking down when Yahoo went through some major HTML/Display rewrites.
While working on the re-write I discovered something that turned 75 LWP requests into two requests; one for the indices information, and one for the list of symbols for which I needed data. The discovery was that Yahoo has a publically facing application server that offers up all financial data in CSV rather than html. I could request ALL the symbols I needed at once, and it was returned in orderly, well formatted, easy to parse CSV.
Needless to say, I saw a significant performance increase.
Yesterday I was asked if I could create a small web application that allowed users to get current currency exchange rates, and rather than re-inventing the wheel, I went back to the stock work I had done and found that the same server would do the exchange for you if given the correct URL. I have included an example of a correct URL, but I am leaving getting the correct Country Currency codes as an exercise to the user. They are readily available from a few different sources.
Usage might be somethig like:
print "Content-type: text/html\n\n";
my $q = new CGI;
if ($q->param("s") && $q->param("s") ne "DUH" && $q->param("t")ne "DUH
my $sym = $q->param("s").$q->param("t")."=X";
my ($factor, $date, $time) = (&GetFactor($sym))[2,3,4];
$time =~ s/"//g;
$date =~ s/"//g;
print '<CENTER><p><b><font face="Arial" size="4">RESULTS:</font></
printf("<b><font face=\"Arial\" color=\"#0000FF\" size=\"4\">%s %s
+ = %s %s as of %s, %s </font></b></p>",&commify($q->param("a")), $q->
+param("s"), &commify(($factor*$q->param("a"))), $q->param("t"),$date,