nodejs使用fetch抓取geojson
2021-03-09 18:30
标签:turn text i++ res get got awl length pre 地图geojson http://datav.aliyun.com/tools/atlas/#&lat=33.90689555128866&lng=113.5052490234375&zoom=7 抓取代码 nodejs使用fetch抓取geojson 标签:turn text i++ res get got awl length pre 原文地址:https://www.cnblogs.com/windyWu/p/12862717.htmlconst fetch = require(‘node-fetch‘);
var fs = require("fs")
async function scrawl(code) {
console.log(code + "gotten")
if (code % 100 == 0) {
let target = code + "_full";
let result = await fetch(`https://geo.datav.aliyun.com/areas_v2/bound/${target}.json`)
let text = await result.text()
fs.writeFileSync("data/" + target + ".json", text)
let json = JSON.parse(text)
let features = json.features;
for (let i = 0; i ) {
let childCode = features[i].properties.adcode
await scrawl(childCode)
}
return;
}
let result = await fetch(`https://geo.datav.aliyun.com/areas_v2/bound/${code}.json`)
let text = await result.text()
fs.writeFileSync("data/" + code + ".json", text)
}
scrawl(100000)
上一篇:Html5——WebSocket
下一篇:递归格式化JSON数据
文章标题:nodejs使用fetch抓取geojson
文章链接:http://soscw.com/index.php/essay/62407.html