YQL yahoo.finance.analystestimate results -
i trying use yql yahoo financial data. checked show community table
on yql console see database under yahoo tag.
posted sample yql:
https://developer.yahoo.com/yql/console/?q=show%20tables&env=store://datatables.org/alltableswithkeys#h=select+*+from+yahoo.finance.analystestimate+where+symbol%3d'prlb'
got result this:
"results": { "results": { "symbol": "prlb" } }
i have expected formatted data, taken here, earnings estimates, eps trends... same happens similar tables.
doing wrong?
the js table not working anymore ie needs fixed.
this partially formatted...
<?xml version="1.0" encoding="utf-8"?> <table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> <meta> <author><!-- name or company name --></author> <description><!-- description of table --></description> <documentationurl><!-- url api documentation --></documentationurl> <apikeyurl><!-- url getting api key if needed --></apikeyurl> <samplequery>select * {table}</samplequery> </meta> <bindings> <select itempath="" produces="xml"> <urls> <url><!-- rest endpoint select data --></url> </urls> <inputs> <key id="" type="xs:string" paramtype="query" /> </inputs> <execute> <![cdata[ function getelement(row) { if(row.hasownproperty("p")) return(row.p.text()); return(row.font.text()); } // setup query finance.yahoo.com var url="http://finance.yahoo.com/q/ae?s=" + symbol; var restquery = y.rest( url ); var rawresult = restquery.accept( "text/html" ).get().response; var aequery = y.xpath( rawresult, "//table[@class='yfnc_tableout1']/tr[count(td)=0]/parent::*|" + "//table[@class='yfnc_tableout1']/tr/td/table" ); // process results var aedata = <results symbol={symbol}></results>; var = 0; while(i < aequery.length()) { var table = aequery[i]; var thead = table.tr[0]; var tname = thead.th[0].strong.text().tostring().replace(/ /g, ""); var fname1 = thead.th[1].p.text().tostring().replace(/\n.*/, ""); var fname2 = thead.th[2].p.text().tostring().replace(/\n.*/, ""); var fname3 = thead.th[3].p.text().tostring().replace(/\n.*/, ""); var fname4 = thead.th[4].p.text().tostring().replace(/\n.*/, ""); fname1 = fname1.replace(/[\s\.]+/g, "").replace(/\&/,""); fname2 = fname2.replace(/[\s\.]+/g, "").replace(/\&/,""); fname3 = fname3.replace(/[\s\.]+/g, "").replace(/\&/,""); fname4 = fname4.replace(/[\s\.]+/g, "").replace(/\&/,""); var tblval = <{tname}></{tname}>; var j = 1; while(j < table.tr.length()) { var row = table.tr[j].td; var rname = row[0].p.text().tostring().replace(/[\s\.]+/g, ""); rname = rname.replace(/\(.*\)/g,"").replace(/\%/,"").replace(/^(\d)/,"_$1"); rname = rname.replace(/\//, ""); var rval1 = getelement(row[1]); var rval2 = getelement(row[2]); var rval3 = getelement(row[3]); var rval4 = getelement(row[4]); tblval.appendchild(<{rname}> <{fname1}>{rval1}</{fname1}> <{fname2}>{rval2}</{fname2}> <{fname3}>{rval3}</{fname3}> <{fname4}>{rval4}</{fname4}> </{rname}>); j = j + 1; } aedata.appendchild(tblval); = + 1; } // return aedata strucuture response.object = aedata; ]]> </execute> </select> </bindings> </table>
Comments
Post a Comment