eval(read('/apps/notex.jsx'));
notex.usage('Get stock quotes', {symbol: 'The stock symbol to quote'});
             
// Get the stock symbol parameter
var symbol = param('symbol'); if (!symbol) notex.error('No symbol');
var url = 'http://finance.yahoo.com/q?s=' + symbol;

// Read the stock quote web page as XHTML (and cache it for 60 seconds)
var xhtml = GET('/apps/demo/services/translate/xhtml.php?token=' + notex.token + '&url=' + escape(url), 60);

// Strip the namespace attribute and remove all XHTML entities (e.g. "&nbsp;")
var xml = xhtml.replace(/ xmlns="[^"]+"/, '').replace(/&\w+?;/g, '').toXML();

// Now return the stock quote by extracting the "Last Trade:" from the XHTML
var price = xml..tr.(th=='Last Trade:').td.big.b.span;

var out =
<quote>
  <symbol>{ symbol }</symbol>
  <price>{ price.toString() }</price>
  <source>http://finance.yahoo.com/</source>
</quote>

write(out.toXMLString());
