Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update yahoo.finance.analystestimate.xml #457

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 46 additions & 35 deletions yahoo/finance/yahoo.finance.analystestimate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
function getelement(row)
{
if(row.hasOwnProperty("p")) return(row.p.text());
return(row.font.text());
else if(row.hasOwnProperty("font")) return(row.font.text());
return row.text();
}

// Setup Query from finance.yahoo.com
Expand All @@ -32,8 +33,8 @@
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"
"//table[@class='yfnc_tableout1']/tbody/tr[count(td)=0]/parent::*/parent::*|"+
"//table[@class='yfnc_tableout1']/tbody/tr/td/table"
);

// Process Results
Expand All @@ -42,38 +43,49 @@
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 thead = table.tbody.tr[0];
if(thead)
{
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);
var tname = thead.th[0].strong.text().toString().replace(/ /g, "");
var fname1 = thead.th[1].text().toString().replace(/\n.*/, "");
var fname2 = thead.th[2].text().toString().replace(/\n.*/, "");
var fname3 = thead.th[3].text().toString().replace(/\n.*/, "");
var fname4 = thead.th[4].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.tbody.tr.length())
{
var tr = table.tbody.tr[j];
if(tr)
{
var row=tr.td;
if(row)
{
var rname = row[0].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);
}
i = i + 1;
}

Expand All @@ -84,4 +96,3 @@
</select>
</bindings>
</table>