页面地址:http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2021/11/01/01/110101001.html 最近需要使用最新的行政区划信息,虽然统计局公开了相关的数据,但是并没有提供数据文件。于是,就写了个爬虫把所有的数据爬取了一遍。生成的默认数据格式为json,另外提供了一个工具来把json转成csv。
转换工具使用说明:
(venv) (base) zhongming@ZhongMingdeMacBook-Pro get_district % python json2csv.py **************************************************************************************************** 国家统计局行政区划爬虫 Json转CSV http://h4ck.org.cn obaby@mars Usage: json2csv -a -i <inputfile> -o <outputfile> -a 转换当前目录下所有json文件 -i json文件 -o 转换后的csv文件 ****************************************************************************************************
代码结构:
csv文件内容:
province_name,city_name,city_code,town_name,town_code,villagetr_name,villagetr_code,street_name,street_code,street_type 浙江省,杭州市,330100000000,上城区,330102000000,清波街道,330102001000,清波门社区,330102001051,111 浙江省,杭州市,330100000000,上城区,330102000000,清波街道,330102001000,劳动路社区,330102001052,111 浙江省,杭州市,330100000000,上城区,330102000000,清波街道,330102001000,定安路社区,330102001053,111 浙江省,杭州市,330100000000,上城区,330102000000,清波街道,330102001000,清河坊社区,330102001055,111 浙江省,杭州市,330100000000,上城区,330102000000,清波街道,330102001000,柳翠井巷社区,330102001057,111 浙江省,杭州市,330100000000,上城区,330102000000,湖滨街道,330102003000,涌金门社区,330102003050,111 浙江省,杭州市,330100000000,上城区,330102000000,湖滨街道,330102003000,青年路社区,330102003052,111 浙江省,杭州市,330100000000,上城区,330102000000,湖滨街道,330102003000,东平巷社区,330102003053,111 浙江省,杭州市,330100000000,上城区,330102000000,湖滨街道,330102003000,岳王路社区,330102003055,111 浙江省,杭州市,330100000000,上城区,330102000000,湖滨街道,330102003000,东坡路社区,330102003057,111 浙江省,杭州市,330100000000,上城区,330102000000,湖滨街道,330102003000,吴山路社区,330102003058,111 浙江省,杭州市,330100000000,上城区,330102000000,小营街道,330102004000,小营巷社区,330102004051,111 浙江省,杭州市,330100000000,上城区,330102000000,小营街道,330102004000,马市街社区,330102004052,111 浙江省,杭州市,330100000000,上城区,330102000000,小营街道,330102004000,紫金社区,330102004053,111 浙江省,杭州市,330100000000,上城区,330102000000,小营街道,330102004000,老浙大社区,330102004057,111 浙江省,杭州市,330100000000,上城区,330102000000,小营街道,330102004000,大学路社区,330102004058,111 浙江省,杭州市,330100000000,上城区,330102000000,小营街道,330102004000,葵巷社区,330102004059,111 浙江省,杭州市,330100000000,上城区,330102000000,小营街道,330102004000,茅廊巷社区,330102004060,111 浙江省,杭州市,330100000000,上城区,330102000000,小营街道,330102004000,金钱巷社区,330102004061,111 浙江省,杭州市,330100000000,上城区,330102000000,小营街道,330102004000,梅花碑社区,330102004062,111 浙江省,杭州市,330100000000,上城区,330102000000,小营街道,330102004000,长明寺巷社区,330102004063,111 浙江省,杭州市,330100000000,上城区,330102000000,小营街道,330102004000,姚园寺巷社区,330102004064,111 浙江省,杭州市,330100000000,上城区,330102000000,小营街道,330102004000,西牌楼社区,330102004065,111 浙江省,杭州市,330100000000,上城区,330102000000,南星街道,330102008000,馒头山社区,330102008051,111 浙江省,杭州市,330100000000,上城区,330102000000,南星街道,330102008000,美政桥社区,330102008053,111 浙江省,杭州市,330100000000,上城区,330102000000,南星街道,330102008000,紫花埠社区,330102008055,111 浙江省,杭州市,330100000000,上城区,330102000000,南星街道,330102008000,海月桥社区,330102008058,111 浙江省,杭州市,330100000000,上城区,330102000000,南星街道,330102008000,白塔岭社区,330102008059,111 浙江省,杭州市,330100000000,上城区,330102000000,南星街道,330102008000,复兴街社区,330102008060,111 浙江省,杭州市,330100000000,上城区,330102000000,南星街道,330102008000,玉皇山社区,330102008061,111 浙江省,杭州市,330100000000,上城区,330102000000,南星街道,330102008000,水澄桥社区,330102008062,111 浙江省,杭州市,330100000000,上城区,330102000000,紫阳街道,330102009000,十五奎巷社区,330102009051,111 浙江省,杭州市,330100000000,上城区,330102000000,紫阳街道,330102009000,北落马营社区,330102009052,111 浙江省,杭州市,330100000000,上城区,330102000000,紫阳街道,330102009000,彩霞岭社区,330102009055,111 浙江省,杭州市,330100000000,上城区,330102000000,紫阳街道,330102009000,候潮门社区,330102009056,111 浙江省,杭州市,330100000000,上城区,330102000000,紫阳街道,330102009000,太庙社区,330102009058,111 浙江省,杭州市,330100000000,上城区,330102000000,紫阳街道,330102009000,木场巷社区,330102009059,111 浙江省,杭州市,330100000000,上城区,330102000000,紫阳街道,330102009000,新工社区,330102009060,111 浙江省,杭州市,330100000000,上城区,330102000000,紫阳街道,330102009000,凤凰社区,330102009061,111
数据库以及代码地址:
3 comments
有考虑过没有区或者县的情况吗
和区县没关系,只要网站的数据层级结构是对的就可以了。
感谢分享