开发者

Get Only One Part Of a CSV URL

If you take a look at Yahoo Finance, you may notice that you can retrieve information from their servers using a URL, that might lead to a CSV file. Let's use as example this URL: http://download.开发者_如何转开发finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=USDBRL=X, it will return this:

"USDBRL=X",1.6294,"3/31/2011","12:06pm"

But how I can use that URL to retrieve that information and store only the money value(1.6294) part using Javascript?


The simplest solution is to split the string into an array using str.split(",") and take the second element. This is not completely bulletproof (it assumes there are no commas in the first column), but it might be robust enough for a simple script.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜