Skip to content

Commit

Permalink
Fix upstream yql#447
Browse files Browse the repository at this point in the history
These changes should fix the problem described in yql#447
  • Loading branch information
johnmwilson82 committed Apr 13, 2015
1 parent 053e0d6 commit 1794361
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions yahoo/finance/yahoo.finance.keystats.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@
</inputs>
<execute>
<![CDATA[
//UTILITY: pad string with leading char
//UTILITY: pad string with leading char
String.prototype.pad = function ( padchar, padlen )
{
s = this
while (s.length < padlen)
{
s = padchar + s;
}
return s;
}
//UTILITY: convert string to INTEGER
//UTILITY: convert string to INTEGER
String.prototype.toInt = function ()
{
// remove leading 0's because otherwise
// remove leading 0's because otherwise
// str can be interpreted as Octal
var str = this.replace( /^0+/, '' );
Expand All @@ -51,8 +51,8 @@
//str = str.replace(/B/g,'000000000');
return parseInt( str );
}
//UTILITY: trim whitespace
}
//UTILITY: trim whitespace
String.prototype.trim = function ()
{
var str = this.replace( /^\s\s*/, "" ),
Expand All @@ -61,16 +61,16 @@
while ( ws.test( str.charAt( --i ) ) );
return str.slice( 0, i + 1 );
}
// Setup Query from finance.yahoo.com
var url="http://finance.yahoo.com/q/ks?s=" + symbol;
var restquery = y.rest( url );
var restquery = y.rest( url );
var rawresult = restquery.accept( "text/html" ).get().response;
var keystatsquery = y.xpath(
rawresult,
"//table[@class='yfnc_datamodoutline1']/tr/td/table/tr" +
"//table[@class='yfnc_datamodoutline1']/tbody/tr/td/table/tbody/tr" +
"/td[@class='yfnc_tabledata1' or @class='yfnc_tablehead1']"
);
);
// Process Results
Expand All @@ -79,7 +79,7 @@
{
var i = 0;
while ( i < keystatsquery.length())
while ( i < keystatsquery.length())
{
// Setup to Process Two 'td' Elements at a Time - Name and Value Pairs
var td_param_name = keystatsquery[i];
Expand All @@ -88,9 +88,9 @@
var attr = "";
var value = "";
i = i + 2;
// Process Parameter Name and any Associated Attributes (Timeframe, Stock Split Info)
param_name = td_param_name.p.text().toString();
param_name = td_param_name.text().toString();
param_name = String(param_name.replace(/:/g,""));
attr = String(param_name.match(/\(.*\)/));
attr = String(attr.trim());
Expand All @@ -105,7 +105,7 @@
param_name = param_name.trim();
// Process Value Information
value = td_value.p.text().toString();
value = td_value.text().toString();
// Catch When it is Span Tag instead of P tag
if( value == false){
value = td_value.span.text().toString();
Expand All @@ -119,16 +119,16 @@
if(attr !== "null"){ statsdata.appendChild(<{param_name} term={attr}> {value} </{param_name}>);}
else { statsdata.appendChild(<{param_name}> {value} </{param_name}>);}
}
}
}
// Return statsdata strucuture
response.object = statsdata;
]]>
</execute>
</select>
Expand Down

0 comments on commit 1794361

Please sign in to comment.