Răsfoiți Sursa

国家统计局最新数据(截止时间:2016-07-31,发布时间:2017-05-16)

modood 8 ani în urmă
părinte
comite
d5a8cf3e48
11 a modificat fișierele cu 22 adăugiri și 22 ștergeri
  1. 2 2
      README.md
  2. 0 0
      dist/address2.json
  3. 0 0
      dist/address3.json
  4. 0 0
      dist/address4.json
  5. 0 0
      dist/areas.json
  6. 0 0
      dist/cities.json
  7. 0 0
      dist/streets.json
  8. 4 4
      index.js
  9. 1 1
      package.json
  10. 6 6
      spider.js
  11. 9 9
      test/json.js

+ 2 - 2
README.md

@@ -12,8 +12,8 @@
     * [中华人民共和国国家统计局-行政区划代码](http://www.stats.gov.cn/tjsj/tjbz/xzqhdm/)
     * [中华人民共和国国家统计局-统计用区划和城乡划分代码](http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/)
 *   本项目已更新至:
-    * [最新县及县以上行政区划代码(截止时间:2015-9-30,发布时间:2016-08-09)](http://www.stats.gov.cn/tjsj/tjbz/xzqhdm/201608/t20160809_1386477.html)
-    * [2015年统计用区划代码和城乡划分代码(截止时间:2015-09-30,发布时间:2016-07-27)](http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2015/index.html)
+    * [最新县及县以上行政区划代码(截止时间:2016-07-31,发布时间:2017-03-10)](http://www.stats.gov.cn/tjsj/tjbz/xzqhdm/201703/t20170310_1471429.html)
+    * [2016年统计用区划代码和城乡划分代码(截止时间:2016-07-31,发布时间:2017-05-16)](http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/index.html)
 
 ## JSON
 

Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/address2.json


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/address3.json


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/address4.json


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/areas.json


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/cities.json


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/streets.json


+ 4 - 4
index.js

@@ -70,15 +70,15 @@ function getAddressPC (provinces, cities) {
   var doc = {}
 
   // 过滤三级联动时才有效的名称
-  var filterName = ['市辖区', '县', '省直辖县级行政区划', '自治区直辖县级行政区划'];
+  var filterName = ['县', '省直辖县级行政区划', '自治区直辖县级行政区划']
 
   provinces.forEach(function (p) {
     doc[p.name] = cities.filter(function (c) {
-      return p.code === c.parent_code && filterName.every(function(filterName) {
-        return c.name != filterName;
+      return p.code === c.parent_code && filterName.every(function (filterName) {
+        return c.name !== filterName
       })
     }).map(function (c) {
-      return c.name
+      return c.name === '市辖区' ? p.name : c.name
     })
   })
 

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "china-division",
-  "version": "1.0.4",
+  "version": "1.1.0",
   "description": "中华人民共和国行政区划:省份、城市、区县、乡镇(街道)",
   "main": "index.js",
   "scripts": {

+ 6 - 6
spider.js

@@ -14,8 +14,8 @@ var i = 0
  * @datetime 2016-12-19 16:32
  */
 function fetch (callback) {
-  // 数据截止2015年9月30日(发布时间:2016-08-09 11:28
-  http.get('http://www.stats.gov.cn/tjsj/tjbz/xzqhdm/201608/t20160809_1386477.html', function (res) {
+    // 数据截止 2016 年 07 月 31 日(发布时间:2017-03-10 10:33
+  http.get('http://www.stats.gov.cn/tjsj/tjbz/xzqhdm/201703/t20170310_1471429.html', function (res) {
     var rawData = ''
     var statusCode = res.statusCode
 
@@ -35,7 +35,7 @@ function fetch (callback) {
     res.on('end', function () {
       var current
       var result = {}
-      var reg = /<span lang="EN-US">(.*?)<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><span style="font-family: 宋体">(.*?)<\/span>/g
+      var reg = /<span lang="EN-US">(.*?)<span>(?:&nbsp;)+ <\/span><\/span>(?:<\/b>)?(?:<b>)?<span style="font-family: 宋体">(.*?)<\/span>/g
 
       while ((current = reg.exec(rawData)) !== null) {
         result[current[1]] = current[2].trim()
@@ -63,8 +63,8 @@ function fetchStreets (area, total, callback) {
     default: html = areaCode.substr(0, 2) + '/' + areaCode.substr(2, 2) + '/' + areaCode + '.html'
   }
 
-  // 数据截止2015年9月30日(发布时间:2016-07-27
-  http.get('http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2015/' + html, function (res) {
+  // 数据截止 2016 年 07 月 31 日(发布时间:2017-05-16
+  http.get('http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/' + html, function (res) {
     var bufferHelper = new BufferHelper()
     var statusCode = res.statusCode
 
@@ -126,7 +126,7 @@ function pick (callback) {
           name: data[k],
           parent_code: k.substr(0, 2) + '0000'
         })
-      } else if (k.substr(4, 2) !== '00') {
+      } else if (k.substr(4, 2) !== '00' && data[k] !== '市辖区') {
         // 区县数据
         areas.push({
           code: k,

+ 9 - 9
test/json.js

@@ -6,17 +6,17 @@
  * @DateTime 2016-10-10 11:24
  */
 
-const assert = require('assert')
+var assert = require('assert')
 
-const chinaDivision = require('..')
+var chinaDivision = require('..')
 
-const provinces = chinaDivision.provinces
-const cities = chinaDivision.cities
-const areas = chinaDivision.areas
-const streets = chinaDivision.streets
-const address2 = chinaDivision.address2
-const address3 = chinaDivision.address3
-const address4 = chinaDivision.address4
+var provinces = chinaDivision.provinces
+var cities = chinaDivision.cities
+var areas = chinaDivision.areas
+var streets = chinaDivision.streets
+var address2 = chinaDivision.address2
+var address3 = chinaDivision.address3
+var address4 = chinaDivision.address4
 
 describe('中华人民共和国行政区划:', function () {
   it('省份数据', function () {

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff