/**
* Date: 2018/10/1
* Author: xuzhiteng
* Description:
* 1. 根据标签获取最外层元素
* 2. 遍历获取出所有链接
* 2.1 封装方法 ==> str转换为dom元素
* 2.1 将链接str转换为dom元素,获取FPT下载详细链接;
* 3. 换行打印出下载链接
* Tips: https://www.dy2018.com/ 网站的元素标签是动态变换的,需要手动更新标签;
**/
var attrName = "nsbbfeli";
var urls = [];
var alls = document.getElementById("Zoom").getElementsByTagName("anchor");
function parseToDOM(str){
var div = document.createElement("div");
if(typeof str == "string")
div.innerHTML = str;
return div.childNodes;
}
function getAllDowmUrl(){
for(var i=0;i<alls.length;i++) {
var domStr = parseToDOM(alls[i].innerHTML);
var url = domStr[0].getAttribute(attrName);
urls.push(url+"\r\n");
}
console.log(urls.toString());
}
getAllDowmUrl();
原文地址:https://www.cnblogs.com/xuzhuteng/p/9734975.html