var x = document.getElementsByClassName(‘tbspan‘); var y = new Array(x.length); var temparr = new Array(); var fname,fscore; for (var i=0;i<x.length;i++) { y[i]=x[i].getElementsByTagName(‘tr‘)[3].getElementsByTagName(‘td‘)[0].textContent; } for (var a=0;a<y.length;a++) { temparr = y[a].split(‘◎‘); fname = temparr[1]; if (temparr[9].indexOf("豆瓣评分")>=0) { fscore = temparr[9]; } else { fscore = temparr[10]; } document.write(a+1+" "+fname+" -> "+fscore+"<br />"); }
原文:http://www.cnblogs.com/jhcla/p/5507093.html