全国城市数据@TOC
全国城市数据
数据来源 中华人民共和国民政部 根据国家发布的最新城市数据进行处理
访问页面查看数据
2020年中华人民共和国县以上行政区划代码(截止2020年12月31日)
点击后可查看全国县以上数据。
抓取数据
这个是急慌慌写出来的,然后就插到了我们自己的数据库了,感兴趣的可以看一下。
其中有个 com.fy.utils.JsonUtils 工具类 自己使用ObjectMapper即可,这里就不再单独展示了。
使用了jsoup对html进行处理
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.11.3</version>
</dependency>
实体
/**
*
*/
package com.fy.utils;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @author
*
*/
public class CityModel implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private Long code;
private String name;
private int layer;
private Long parent;
private List<CityModel> children = new ArrayList<CityModel>();
public Long getCode() {
return code;
}
public void setCode(Long code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getLayer() {
return layer;
}
public void setLayer(int layer) {
this.layer = layer;
}
public Long getParent() {
return parent;
}
public void setParent(Long parent) {
this.parent = parent;
}
public List<CityModel> getChildren() {
return children;
}
public void setChildren(List<CityModel> children) {
this.children = children;
}
/*
* @Override public String toString() {