Javascript code to extract info from source code of webpage.

June 14, 2012 at 21:12:06
Specs: Windows 7
Hi. I need to write a javascript program that will extract and display info like Temperature, Humidity, Sunrise, Sunset and Chance of Precipitation from the source code of this webpage. For a simpler source code, I am able to extract information but this source code is very complicated, so your help will be much appreciated!

See More: Javascript code to extract info from source code of webpage.

Report •

#1
June 14, 2012 at 22:19:09
I found the following code, which maybe helpful in coming up with a solution to my problem.

function getElementsByTagNames(list,obj) {
if (!obj) var obj = document;
var tagNames = list.split(',');
var resultArray = new Array();
for (var i=0;i<tagNames.length;i++) {
var tags = obj.getElementsByTagName(tagNames[i]);
for (var j=0;j<tags.length;j++) {
resultArray.push(tags[j]);
}
}
var testNode = resultArray[0];
if (!testNode) return [];
if (testNode.sourceIndex) {
resultArray.sort(function (a,b) {
return a.sourceIndex - b.sourceIndex;
});
}
else if (testNode.compareDocumentPosition) {
resultArray.sort(function (a,b) {
return 3 - (a.compareDocumentPosition(b) & 6);
});
}
return resultArray;
}


Report •
Related Solutions


Ask Question