{"id":13534048,"url":"https://github.com/wecatch/china_regions","last_synced_at":"2025-05-15T01:09:24.926Z","repository":{"id":32299243,"uuid":"35874211","full_name":"wecatch/china_regions","owner":"wecatch","description":"最全最新中国省，市，地区json及sql数据","archived":false,"fork":false,"pushed_at":"2022-12-09T19:43:05.000Z","size":50694,"stargazers_count":3089,"open_issues_count":35,"forks_count":915,"subscribers_count":82,"default_branch":"master","last_synced_at":"2025-04-13T23:53:52.741Z","etag":null,"topics":["china","china-city","china-location","china-regions"],"latest_commit_sha":null,"homepage":"http://wecatch.me/china_regions/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wecatch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-19T10:00:01.000Z","updated_at":"2025-04-10T01:48:18.000Z","dependencies_parsed_at":"2023-01-14T21:01:29.680Z","dependency_job_id":null,"html_url":"https://github.com/wecatch/china_regions","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wecatch%2Fchina_regions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wecatch%2Fchina_regions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wecatch%2Fchina_regions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wecatch%2Fchina_regions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wecatch","download_url":"https://codeload.github.com/wecatch/china_regions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254254043,"owners_count":22039792,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["china","china-city","china-location","china-regions"],"created_at":"2024-08-01T07:01:25.796Z","updated_at":"2025-05-15T01:09:19.916Z","avatar_url":"https://github.com/wecatch.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Uncategorized","Applications"],"sub_categories":["Uncategorized","Web Tools"],"readme":"# china_regions\n\n最全最新中国省，市，地区 json 及 sql 数据，自动抓取国标 http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/ 数据，并且自动生成 JavaScript es6 module 以及 sql 数据。\n\n最新国标行政区规划最低到居委会这一级别了，行政区代码代码也变长了，不包含港澳台信息，按需所需不同的版本，见 https://github.com/wecatch/china_regions/releases\n\n## 演示地址\n\nhttp://wecatch.me/china_regions/\n\n## 如何使用\n\n数据分 json、es6 module、sql 三种格式存储，es6 module 和 sql 是根据 json 自动生成，json 数据又是根据最新国标生成，\n\n```\n├── js              # js module 格式\n├── json            # json 格式\n├── mysql           # mysql sql 格式\n```\n\n直接拷贝 json 和 es6 文件可直接使用，也可以根据对应的语言生成不同的模块。\n\n\nVillage 数据文件特别大，默认不包含在仓库中，可以 clone 仓库，在 src 中解压 village 的压缩文件，然后执行 `python makedata.py`\n\n\n## 如何更新到最新国标\n\n仓库中的现在的数据是根据最新国标生成，如果在使用中发现国标有变动，可以手动进行更新，需要有 node8 或更高环境:\n\n1. git clone 本仓库\n2. yarn install 或者 npm install\n3. 移除 src 目录下的 json 文件：\n\n```\n    ├── city.json\n    ├── country.json\n    ├── province.json\n    ├── source.json\n    ├── town.json\n    └── village.json\n```\n\n4. 打开 main.js 文件，取消对 main 函数执行的注释，开始执行 `node main.js`，一般情况下可以顺利爬取到 province、\ncity、country 的信息\n5. 利用已经爬取的 province、city、country 开始同步其他行政区域的信息，注释掉 main 函数根据需要分别打开 pullTownDataSync、pullVillageDataSync 爬取其他行政区域的信息，注释事项见函数注释\n6. 最后执行 `python makedata.py` 生成各种格式文件\n\n## 注意事项\n\n根据 town 爬取的 village 数据非常大，默认情况下不会自动生成 village 的信息，可以根据自己的需要 clone 仓库之后自己生成\n\n行政级别顺序是:province-\u003e city --\u003e country --\u003e town --\u003e village，对应的是:省-\u003e市(市辖区)-\u003e县(区、市)-\u003e镇(街道)-\u003e村(居委会)\n\n爬取 village 时由于数据量特别大会导致 nodejs 出现内存泄漏的情况，所以每次增量更新文件时会自动进行文件备份，生成 `src/village_backup.json` 备份文件不进仓库，最后再手动干预偏移量\n\nvillage 的数据文件是压缩过的解压执行 `tar xvfz village.tar.gz .`\n\n默认情况下不生成 village 这个级别的数据，如果需要请执行 `makedata.py` \n\n\n## 反馈\n\n如果国标页面 html 结构发生变化，请提 issue。\n\n\n## 更新记录\n\n## 2021.2.23 \n\n更新到 http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2020/index.html 2020 最新数据\n\n## 2019.4.17\n\nfix [#17](https://github.com/wecatch/china_regions/issues/17) 针对东莞市 中山市 儋州市三个不设区的市单独处理，\n这三个市没有区，直接到镇 town，镇的上一级就是市，开发者可以根据自己的情况特殊处理，详见 `src/special_city.json`，SQL 数据包含在 town.sql 中\n\n## 2019.4.9\n\n- fix [#16](https://github.com/wecatch/china_regions/issues/16)\n\n## 2019.3.10\n\n- 更新数据生成的方式\n- 校验数据生成是否准确 `cat src/village.json | grep id | wc -l` == `wc -l mysql/village.sql`\n\n## 2019.2.11\n\n- 更新数据抓取方式，使用 nodejs 抓取\n- 更新数据到最新的 2018 国标\n- 移除对 sqlite 以及 postgresql 的\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwecatch%2Fchina_regions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwecatch%2Fchina_regions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwecatch%2Fchina_regions/lists"}