forked from yql/yql-tables
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyahoo.finance.isin.xml
52 lines (46 loc) · 1.33 KB
/
yahoo.finance.isin.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?xml version="1.0" encoding="UTF-8" ?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<sampleQuery>
select * from {table} where symbol in ("US9843321061")
</sampleQuery>
</meta>
<bindings>
<select itemPath="" produces="XML">
<urls><url></url></urls>
<inputs>
<key id='symbol' type='xs:string' paramType='variable' required='true' />
</inputs>
<execute><![CDATA[
// pad string with leading char
String.prototype.pad = function (padchar, padlen) {
s = this
while (s.length < padlen) {
s = padchar + s;
}
return s;
}
String.prototype.trim = function () {
var str = this.replace(/^\s\s*/, ''),
ws = /\s/,
i = str.length;
while (ws.test(str.charAt(--i)));
return str.slice(0, i + 1);
}
//var url = "http://finance.yahoo.com/lookup?s="+symbol;
var url = "http://finance.yahoo.com/q/ks?s=yhoo";
var isinQuery = y.query(
"select * from html " +
"where url=@url and " +
"xpath='" +
"//table'" ,
//"//table[@summary = \"YFT_SL_TABLE_SUMMARY\"]/tbody/tr[@class = \"yui-dt-odd\" or @class = \"yui-dt-even\"]'" ,
{url:url});
var stock = <stock symbol={symbol}></stock>;
var results = isinQuery.results;
stock.Isin = results.toString().trim();
response.object = stock
]]></execute>
</select>
</bindings>
</table>