代码拉取完成,页面将自动刷新
var provinceNode = document.querySelectorAll("p.MsoNormal b span");
var provinceArray = [];
provinceNode.forEach(function(i, index){
var length = provinceArray.length;
if(length === 0){
provinceArray.push({
"id": i.outerText.trim(),
"name": ''
})
}else if(!provinceArray[length-1].name){
if(i.outerText.trim()){
provinceArray[length-1].name = i.outerText.trim();
}
}else {
if(i.outerText.trim()){
provinceArray.push({
"id": i.outerText.trim(),
"name": ''
})
}
}
});
var cityNode = document.querySelectorAll("p.MsoNormal>span");
var cityArray = [];
cityNode.forEach(function(i, index){
var length = cityArray.length;
if(length === 0){
if (i.outerText.trim()){
cityArray.push({
"id": i.outerText.trim(),
"name": ''
})
}
}else if(!cityArray[length-1].name){
if(i.outerText.trim()){
cityArray[length-1].name = i.outerText.trim();
}
}else {
if(i.outerText.trim()){
cityArray.push({
"id": i.outerText.trim(),
"name": ''
})
}
}
});
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data')
return;
}
if(!filename) filename = 'console.json'
if(typeof data === "object"){
data = JSON.stringify(data, undefined, 4)
}
var blob = new Blob([data], {type: 'text/json'}),
e = document.createEvent('MouseEvents'),
a = document.createElement('a')
a.download = filename
a.href = window.URL.createObjectURL(blob)
a.dataset.downloadurl = ['text/json', a.download, a.href].join(':')
e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
a.dispatchEvent(e)
}
})(console)
console.save(JSON.stringify(cityArray), 'city.json')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。