09月22日, 2014 3173次
var opstr=[];
document.querySelectorAll(".zszc-link").forEach(t=>{
if("zszc-link text-decoration-none"==t.getAttribute("class")){
var text=t.parentNode.children[0].innerText;
var url="https://gaokao.chsi.com.cn/"+t.getAttribute("href");
console.log(text,url);
opstr.push([text,url]);
}else
{
//console.log(t.parentNode.children[0].innerText)
}
})
var myjson=JSON.stringify(opstr);
console.log(myjson);
//download(new Date(),myjson)
//download("1.json",myjson)
download(new Date().valueOf()+".json",myjson)
download=function(fileName,str) {
const content = str
const blob = new Blob([content], {
type: 'application/text'
})
if ('download' in document.createElement('a')) { // 支持a标签download的浏览器
const link = document.createElement('a') // 创建a标签
link.download = fileName // a标签添加属性
link.style.display = 'none'
link.href = URL.createObjectURL(blob)
document.body.appendChild(link)
link.click() // 执行下载
URL.revokeObjectURL(link.href) // 释放url
document.body.removeChild(link) // 释放标签
} else { // 其他浏览器
navigator.msSaveBlob(blob, fileName)
}
}
暂无留言,赶快评论吧