我寫微件程序從彭博社網站 獲得金銀價格的價格這些都是劇本的部分:獲得銀或金率
function getPrice() {
var url = new URL();
url.location = "http://www.bloomberg.com/markets/commodities/futures/";
url.fetchAsync(PriceReturn);
}
function PriceReturn(url) {
var resultStr = url.result;
var subCheck = resultStr.substring(resultStr.indexOf("SILVER"));
foundStr = subCheck.match("[0-9]+\.[0-9]+");
setPrice(parseFloat(foundStr).toFixed(2));
}
我可以得到白銀價格(比方說現在27.30),但是當我想檢查黃金價格(.indexOf("GOLD")
)(比方說現在1,585.60)
什麼是subcheck.match()
腳本來獲得該價格?
。什麼是'URL'? – Neal 2012-07-20 18:37:08
[RegExp for Numbers in the thousandss]中可能有重複(http://stackoverflow.com/questions/8044278/regexp-for-numbers-in-the-thousands) – Dancrumb 2012-07-20 18:41:26