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 to new HTML structure #449

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
22 changes: 14 additions & 8 deletions yahoo/finance/yahoo.finance.analystestimate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
<![CDATA[
function getelement(row)
{
if(row.hasOwnProperty("font")) return(row.font.text());
if(row.hasOwnProperty("p")) return(row.p.text());
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::*|" +
"//table[@class='yfnc_tableout1']/tbody/tr/td/table/tbody"
);

// Process Results
Expand All @@ -44,21 +45,26 @@
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.*/, "");
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(/\&/,"");
// To get constant names (instead of CurrentQtrApr15
fname1 = fname1.replace(/(CurrentQtr).*/g, "$1");
fname2 = fname2.replace(/(NextQtr).*/g, "$1");
fname3 = fname3.replace(/(CurrentYear).*/g, "$1");
fname4 = fname4.replace(/(NextYear).*/g, "$1");

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, "");
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]);
Expand Down