├── LICENSE ├── README.md ├── Urban-and-rural-statistics-spider.py ├── Village-Spider-Test.py ├── data ├── city.csv ├── county.csv ├── province.csv ├── town.csv └── village.csv ├── requirements.txt └── 合并多个csv文件.py /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 国家统计用区划代码和城乡划分代码---源码、详细分析、数据 2 | 3 | --- 4 | 2019.05.25更新: 5 | - [x] 添加了爬虫代码使用说明 6 | - [x] 添加了依赖`requirements.txt` 7 | 8 | 2018.12.02更新: 9 | - [x] 修改[爬虫代码](https://github.com/dta0502/NBSPRC-spider/blob/master/Urban-and-rural-statistics-spider.py),添加了中山市/东莞市下面没有区级单位的异常处理 10 | - [x] 页面源码的编码为`GB2312`,实际为`GBK`,因此手工指定编码为`GBK`:[Issues #2](https://github.com/dta0502/NBSPRC-spider/issues/2) 11 | 12 | 2018.11.30更新: 13 | - [x] 更新`village.csv`文件,按照`code`顺序从小到大排列,看起来更方便 14 | - [x] 更新**数据总结**中的错误 15 | 16 | 2018.11.10更新: 17 | - [x] 缺失数据补充:[Issues #1](https://github.com/dta0502/NBSPRC-spider/issues/1) 18 | 19 | --- 20 | 21 | 22 | ## 一、本仓库介绍 23 | 统计局网站提供的[2016年统计用区划代码和城乡划分代码(截止2016年07月31日)](http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/index.html)按照:`省-市-县-镇-村`这样的层次关系来组织页面。统计局的网站对于爬虫的限制也不多,我只使用一个ip就爬取全部数据,爬取的过程中请求被拒绝的情况很少。 24 | 25 | 本仓库包含: 26 | 27 | - 代码文件: 28 | - [爬虫完整代码](https://github.com/dta0502/China-zoning-code-for-statistics-spider/blob/master/Urban-and-rural-statistics-spider.py) 29 | - [居委会级爬虫代码](https://github.com/dta0502/China-zoning-code-for-statistics-spider/blob/master/Village-Spider-Test.py) 30 | - [居委会数据合并代码](https://github.com/dta0502/NBSPRC-spider/blob/master/%E5%90%88%E5%B9%B6%E5%A4%9A%E4%B8%AAcsv%E6%96%87%E4%BB%B6.py) 31 | 32 | - 2016年统计用区划代码和城乡划分代码数据文件: 33 | - [省级数据.csv](https://github.com/dta0502/China-zoning-code-for-statistics-spider/blob/master/data/province.csv) 34 | - [市级数据.csv](https://github.com/dta0502/China-zoning-code-for-statistics-spider/blob/master/data/city.csv) 35 | - [区级数据.csv](https://github.com/dta0502/China-zoning-code-for-statistics-spider/blob/master/data/county.csv) 36 | - [街道数据.csv](https://github.com/dta0502/China-zoning-code-for-statistics-spider/blob/master/data/town.csv) 37 | - [居委会数据.csv](https://github.com/dta0502/NBSPRC-spider/blob/master/data/village.csv) 38 | 39 | - **页面分析、代码详细说明见个人博客**: 40 | - [国家统计局统计用区划代码和城乡划分代码爬虫-(一)页面分析](https://dta0502.github.io/archives/a4d70246.html) 41 | - [国家统计局统计用区划代码和城乡划分代码爬虫-(二)总体实现](https://dta0502.github.io/archives/796bd537.html) 42 | - [Python合并多个csv文件](https://dta0502.github.io/archives/616c581b.html) 43 | 44 | ## 二、如何使用 45 | ### 1、安装依赖 46 | ```bash 47 | python3 -m pip install -r requirements.txt 48 | ``` 49 | 50 | ### 2、一次性爬取全部数据 51 | ```bash 52 | python3 ./Urban-and-rural-statistics-spider.py 53 | ``` 54 | 55 | ### 3、居委会级数据分段爬取使用说明 56 | 居委会级数据量比较大,一次性爬取可能会出现内存不足,所以我提供了一种**居委会级数据分段爬取,最后合并各段数据的方法**,具体方法如下: 57 | - 省、市、区、街道使用[爬虫完整代码](https://github.com/dta0502NBSPRC-spider/blob/master/Urban-and-rural-statistics-spider.py),其中[居委级爬取部分](https://github.com/dta0502/NBSPRC-spider/blobcf26c7ade170eef874603969fd3858a4cdb747e6Urban-and-rural-statistics-spider.py#L231-L239)注释掉,然后执行: 58 | 59 | ```bash 60 | python3 ./Urban-and-rural-statistics-spider.py 61 | ``` 62 | 63 | 以上爬取完成后,可以看到此目录下已经含有了`town.csv`文件。 64 | 65 | - 然后手动更改[居委会级爬代码](https://github.com/dta0502/NBSPRC-spider/blob/masterUrban-and-rural-statistics-spider.py),具体要修改的部分如下: 66 | 67 | ```python 68 | df_town = pd.read_csv("town.csv",encoding = 'utf-8') 69 | village = getVillage(df_town['link'][0:10000]) 70 | 71 | df_village = pd.DataFrame(village) 72 | # 信息写入csv文件 73 | df_village.to_csv('village-0.csv', sep=',', header=True, index=False) 74 | ``` 75 | 76 | 例如:第一次设置`village = getVillage(df_town['link'][0:10000])`中的爬取链接为`[0-10000]`,同时设置`df_village.to_csv('village-0.csv', sep=',', header=True, index=False)`中的保存文件名为`village-0.csv`。 77 | 78 | - 执行[居委会级爬代码](https://github.com/dta0502/NBSPRC-spider/blob/masterUrban-and-rural-statistics-spider.py): 79 | 80 | ```bash 81 | python3 ./Village-Spider-Test.py 82 | ``` 83 | 84 | 完成第一段爬取后,然后再手动更改爬取链接为`[10000,20000]`,同时保存文件名改为`village-1.csv`,执行以上命令,以此类推,直到全部爬取完成。 85 | 86 | - 全部爬取完毕后,复制各段数据到一个空目录下,在此目录下执行如下代码: 87 | 88 | ```bash 89 | python3 ./合并多个csv文件.py 90 | ``` 91 | 92 | 至此,数据合并完毕,得到完整的居委会级数据。 93 | 94 | ## 三、数据总结 95 | 截止2016年07月31日,我国共有: 96 | - 31个省 97 | - 344个市 98 | - 2852个区 99 | - 42927个街道 100 | - 665062个居委会 101 | -------------------------------------------------------------------------------- /Urban-and-rural-statistics-spider.py: -------------------------------------------------------------------------------- 1 | # 库函数导入 2 | import requests 3 | from lxml import etree 4 | import csv 5 | import time 6 | import pandas as pd 7 | from queue import Queue 8 | from threading import Thread 9 | 10 | 11 | # 网页爬取函数 12 | # 下面加入了num_retries这个参数,经过测试网络正常一般最多retry一次就能获得结果 13 | def getUrl(url,num_retries = 5): 14 | headers = {'User-Agent':"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"} 15 | try: 16 | response = requests.get(url,headers = headers) 17 | response.encoding = 'GBK' 18 | data = response.text 19 | return data 20 | except Exception as e: 21 | if num_retries > 0: 22 | time.sleep(10) 23 | print(url) 24 | print("requests fail, retry!") 25 | return getUrl(url,num_retries-1) #递归调用 26 | else: 27 | print("retry fail!") 28 | print("error: %s" % e + " " + url) 29 | return #返回空值,程序运行报错 30 | 31 | # 获取省级代码函数 32 | def getProvince(url): 33 | province = [] 34 | data = getUrl(url) 35 | selector = etree.HTML(data) 36 | provinceList = selector.xpath('//tr[@class="provincetr"]') 37 | for i in provinceList: 38 | provinceName = i.xpath('td/a/text()') #这里如果采用//a/text()路径会出现问题!! 39 | provinceLink = i.xpath('td/a/@href') 40 | for j in range(len(provinceLink)): 41 | provinceURL = url[:-10] + provinceLink[j] #根据获取到的每个省的链接进行补全,得到真实的URL。 42 | province.append({'name':provinceName[j],'link':provinceURL}) 43 | return province 44 | 45 | # 获取市级代码函数 46 | def getCity(url_list): 47 | city_all = [] 48 | for url in url_list: 49 | data = getUrl(url) 50 | selector = etree.HTML(data) 51 | cityList = selector.xpath('//tr[@class="citytr"]') 52 | #下面是抓取每一个城市的代码、URL 53 | city = [] 54 | for i in cityList: 55 | cityCode = i.xpath('td[1]/a/text()') 56 | cityLink = i.xpath('td[1]/a/@href') 57 | cityName = i.xpath('td[2]/a/text()') 58 | for j in range(len(cityLink)): 59 | cityURL = url[:-7] + cityLink[j] 60 | city.append({'name':cityName[j],'code':cityCode[j],'link':cityURL}) 61 | city_all.extend(city) #所有省的城市信息合并在一起 62 | return city_all 63 | 64 | # 获取区级代码函数---多线程实现 65 | def getCounty(url_list): 66 | queue_county = Queue() #队列 67 | thread_num = 10 #进程数 68 | county = [] #记录区级信息的字典(全局) 69 | 70 | def produce_url(url_list): 71 | for url in url_list: 72 | queue_county.put(url) # 生成URL存入队列,等待其他线程提取 73 | 74 | def getData(): 75 | while not queue_county.empty(): # 保证url遍历结束后能退出线程 76 | url = queue_county.get() # 从队列中获取URL 77 | data = getUrl(url) 78 | selector = etree.HTML(data) 79 | countyList = selector.xpath('//tr[@class="countytr"]') 80 | #下面是爬取每个区的代码、URL 81 | for i in countyList: 82 | countyCode = i.xpath('td[1]/a/text()') 83 | countyLink = i.xpath('td[1]/a/@href') 84 | countyName = i.xpath('td[2]/a/text()') 85 | #上面得到的是列表形式的,下面将其每一个用字典存储 86 | for j in range(len(countyLink)): 87 | countyURL = url[:-9] + countyLink[j] 88 | county.append({'code':countyCode[j],'link':countyURL,'name':countyName[j]}) 89 | 90 | def run(url_list): 91 | produce_url(url_list) 92 | 93 | ths = [] 94 | for _ in range(thread_num): 95 | th = Thread(target = getData) 96 | th.start() 97 | ths.append(th) 98 | for th in ths: 99 | th.join() 100 | 101 | run(url_list) 102 | return county 103 | 104 | # 获取街道代码函数---多线程实现 105 | def getTown(url_list): 106 | queue_town = Queue() #队列 107 | thread_num = 50 #进程数 108 | town = [] #记录街道信息的字典(全局) 109 | 110 | def produce_url(url_list): 111 | for url in url_list: 112 | queue_town.put(url) # 生成URL存入队列,等待其他线程提取 113 | 114 | def getData(): 115 | while not queue_town.empty(): # 保证url遍历结束后能退出线程 116 | url = queue_town.get() # 从队列中获取URL 117 | data = getUrl(url) 118 | selector = etree.HTML(data) 119 | townList = selector.xpath('//tr[@class="towntr"]') 120 | #下面是爬取每个区的代码、URL 121 | for i in townList: 122 | townCode = i.xpath('td[1]/a/text()') 123 | townLink = i.xpath('td[1]/a/@href') 124 | townName = i.xpath('td[2]/a/text()') 125 | #上面得到的是列表形式的,下面将其每一个用字典存储 126 | for j in range(len(townLink)): 127 | # 中山市、东莞市的处理 128 | if url == 'http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4419.html' or url == 'http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4420.html': 129 | townURL = url[:-9] + townLink[j] 130 | else: 131 | townURL = url[:-11] + townLink[j] 132 | town.append({'code':townCode[j],'link':townURL,'name':townName[j]}) 133 | 134 | def run(url_list): 135 | produce_url(url_list) 136 | 137 | ths = [] 138 | for _ in range(thread_num): 139 | th = Thread(target = getData) 140 | th.start() 141 | ths.append(th) 142 | for th in ths: 143 | th.join() 144 | 145 | run(url_list) 146 | return town 147 | 148 | # 获取居委会代码函数---多线程实现 149 | def getVillage(url_list): 150 | queue_village = Queue() #队列 151 | thread_num = 200 #进程数 152 | village = [] #记录街道信息的字典(全局) 153 | 154 | def produce_url(url_list): 155 | for url in url_list: 156 | queue_village.put(url) # 生成URL存入队列,等待其他线程提取 157 | 158 | def getData(): 159 | while not queue_village.empty(): # 保证url遍历结束后能退出线程 160 | url = queue_village.get() # 从队列中获取URL 161 | data = getUrl(url) 162 | selector = etree.HTML(data) 163 | villageList = selector.xpath('//tr[@class="villagetr"]') 164 | #下面是爬取每个区的代码、URL 165 | for i in villageList: 166 | villageCode = i.xpath('td[1]/text()') 167 | UrbanRuralCode = i.xpath('td[2]/text()') 168 | villageName = i.xpath('td[3]/text()') 169 | #上面得到的是列表形式的,下面将其每一个用字典存储 170 | for j in range(len(villageCode)): 171 | village.append({'code':villageCode[j],'UrbanRuralCode':UrbanRuralCode[j],'name':villageName[j]}) 172 | 173 | def run(url_list): 174 | produce_url(url_list) 175 | 176 | ths = [] 177 | for _ in range(thread_num): 178 | th = Thread(target = getData) 179 | th.start() 180 | ths.append(th) 181 | for th in ths: 182 | th.join() 183 | 184 | run(url_list) 185 | return village 186 | 187 | ########################### 188 | ########################### 189 | #省级信息获取 190 | pro = getProvince("http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/index.html") 191 | df_province = pd.DataFrame(pro) 192 | df_province.info() 193 | # 信息写入csv文件 194 | df_province.to_csv('province.csv', sep=',', header=True, index=False) 195 | 196 | ########################### 197 | #市级信息获取 198 | city = getCity(df_province['link']) 199 | df_city = pd.DataFrame(city) 200 | df_city.info() 201 | # 信息写入csv文件 202 | df_city.to_csv('city.csv', sep=',', header=True, index=False) 203 | 204 | ########################### 205 | #区级信息获取 206 | county = getCounty(df_city['link']) 207 | df_county = pd.DataFrame(county) 208 | # 排序:由于多线程的关系,数据的顺序已经被打乱,所以这里按照区代码进行“升序”排序。 209 | df_county_sorted = df_county.sort_values(by = ['code']) #按1列进行升序排序 210 | df_county_sorted.info() 211 | # 信息写入csv文件 212 | df_county_sorted.to_csv('county.csv', sep=',', header=True, index=False) 213 | 214 | ########################### 215 | #街道信息获取 216 | #中山市、东莞市的特殊处理(他们的链接在df_city中) 217 | url_list = list() 218 | for url in df_county['link']: 219 | url_list.append(url) 220 | town_link_list = df_city[df_city['name'].isin(['中山市','东莞市'])]['link'].values 221 | for town_link in town_link_list: 222 | url_list.append(town_link) 223 | town = getTown(url_list) 224 | df_town = pd.DataFrame(town) 225 | # 排序:由于多线程的关系,数据的顺序已经被打乱,所以这里按照街道代码进行“升序”排序。 226 | df_town_sorted = df_town.sort_values(by = ['code']) #按1列进行升序排序 227 | df_town_sorted.info() 228 | # 信息写入csv文件 229 | df_town_sorted.to_csv('town.csv', sep=',', header=True, index=False) 230 | 231 | ########################### 232 | #居委会信息获取 233 | village = getVillage(df_town['link']) 234 | df_village = pd.DataFrame(village) 235 | # 排序:由于多线程的关系,数据的顺序已经被打乱,所以这里按照街道代码进行“升序”排序。 236 | df_village_sorted = df_village.sort_values(by = ['code']) #按1列进行升序排序 237 | df_village_sorted.info() 238 | # 信息写入csv文件 239 | df_village_sorted.to_csv('village.csv', sep=',', header=True, index=False) 240 | -------------------------------------------------------------------------------- /Village-Spider-Test.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # # 居委会信息获取爬虫测试 4 | # 由于居委会的数据量过大,我这里用很小的数据测试其代码是否正确。 5 | 6 | import requests 7 | from lxml import etree 8 | import csv 9 | import time 10 | import pandas as pd 11 | from queue import Queue 12 | from threading import Thread 13 | from fake_useragent import UserAgent 14 | 15 | # 下面加入了num_retries这个参数,经过测试网络正常一般最多retry一次就能获得结果 16 | def getUrl(url,num_retries = 5): 17 | ua = UserAgent() 18 | headers = {'User-Agent':ua.random} 19 | try: 20 | response = requests.get(url,headers = headers) 21 | response.encoding = response.apparent_encoding 22 | data = response.text 23 | return data 24 | except Exception as e: 25 | if num_retries > 0: 26 | time.sleep(10) 27 | print(url) 28 | print("requests fail, retry!") 29 | return getUrl(url,num_retries-1) #递归调用 30 | else: 31 | print("retry fail!") 32 | print("error: %s" % e + " " + url) 33 | return #返回空值,程序运行报错 34 | 35 | def getVillage(url_list): 36 | queue_village = Queue() #队列 37 | thread_num = 20 #进程数 38 | village = [] #记录街道信息的字典(全局) 39 | 40 | def produce_url(url_list): 41 | for url in url_list: 42 | queue_village.put(url) # 生成URL存入队列,等待其他线程提取 43 | 44 | def getData(): 45 | while not queue_village.empty(): # 保证url遍历结束后能退出线程 46 | url = queue_village.get() # 从队列中获取URL 47 | data = getUrl(url) 48 | selector = etree.HTML(data) 49 | villageList = selector.xpath('//tr[@class="villagetr"]') 50 | #下面是爬取每个区的代码、URL 51 | for i in villageList: 52 | villageCode = i.xpath('td[1]/text()') 53 | UrbanRuralCode = i.xpath('td[2]/text()') 54 | villageName = i.xpath('td[3]/text()') 55 | #上面得到的是列表形式的,下面将其每一个用字典存储 56 | for j in range(len(villageCode)): 57 | village.append({'code':villageCode[j],'UrbanRuralCode':UrbanRuralCode[j],'name':villageName[j]}) 58 | 59 | def run(url_list): 60 | produce_url(url_list) 61 | 62 | ths = [] 63 | for _ in range(thread_num): 64 | th = Thread(target = getData) 65 | th.start() 66 | ths.append(th) 67 | for th in ths: 68 | th.join() 69 | 70 | run(url_list) 71 | return village 72 | 73 | 74 | df_town = pd.read_csv("town.csv",encoding = 'utf-8') 75 | village = getVillage(df_town['link'][0:10000]) 76 | 77 | df_village = pd.DataFrame(village) 78 | # 信息写入csv文件 79 | df_village.to_csv('village-0.csv', sep=',', header=True, index=False) 80 | 81 | -------------------------------------------------------------------------------- /data/city.csv: -------------------------------------------------------------------------------- 1 | code,name,link 2 | 110100000000,市辖区,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/11/1101.html 3 | 120100000000,市辖区,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/12/1201.html 4 | 130100000000,石家庄市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/13/1301.html 5 | 130200000000,唐山市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/13/1302.html 6 | 130300000000,秦皇岛市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/13/1303.html 7 | 130400000000,邯郸市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/13/1304.html 8 | 130500000000,邢台市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/13/1305.html 9 | 130600000000,保定市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/13/1306.html 10 | 130700000000,张家口市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/13/1307.html 11 | 130800000000,承德市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/13/1308.html 12 | 130900000000,沧州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/13/1309.html 13 | 131000000000,廊坊市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/13/1310.html 14 | 131100000000,衡水市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/13/1311.html 15 | 139000000000,省直辖县级行政区划,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/13/1390.html 16 | 140100000000,太原市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/14/1401.html 17 | 140200000000,大同市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/14/1402.html 18 | 140300000000,阳泉市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/14/1403.html 19 | 140400000000,长治市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/14/1404.html 20 | 140500000000,晋城市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/14/1405.html 21 | 140600000000,朔州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/14/1406.html 22 | 140700000000,晋中市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/14/1407.html 23 | 140800000000,运城市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/14/1408.html 24 | 140900000000,忻州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/14/1409.html 25 | 141000000000,临汾市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/14/1410.html 26 | 141100000000,吕梁市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/14/1411.html 27 | 150100000000,呼和浩特市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/15/1501.html 28 | 150200000000,包头市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/15/1502.html 29 | 150300000000,乌海市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/15/1503.html 30 | 150400000000,赤峰市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/15/1504.html 31 | 150500000000,通辽市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/15/1505.html 32 | 150600000000,鄂尔多斯市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/15/1506.html 33 | 150700000000,呼伦贝尔市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/15/1507.html 34 | 150800000000,巴彦淖尔市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/15/1508.html 35 | 150900000000,乌兰察布市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/15/1509.html 36 | 152200000000,兴安盟,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/15/1522.html 37 | 152500000000,锡林郭勒盟,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/15/1525.html 38 | 152900000000,阿拉善盟,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/15/1529.html 39 | 210100000000,沈阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/21/2101.html 40 | 210200000000,大连市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/21/2102.html 41 | 210300000000,鞍山市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/21/2103.html 42 | 210400000000,抚顺市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/21/2104.html 43 | 210500000000,本溪市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/21/2105.html 44 | 210600000000,丹东市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/21/2106.html 45 | 210700000000,锦州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/21/2107.html 46 | 210800000000,营口市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/21/2108.html 47 | 210900000000,阜新市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/21/2109.html 48 | 211000000000,辽阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/21/2110.html 49 | 211100000000,盘锦市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/21/2111.html 50 | 211200000000,铁岭市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/21/2112.html 51 | 211300000000,朝阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/21/2113.html 52 | 211400000000,葫芦岛市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/21/2114.html 53 | 220100000000,长春市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/22/2201.html 54 | 220200000000,吉林市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/22/2202.html 55 | 220300000000,四平市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/22/2203.html 56 | 220400000000,辽源市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/22/2204.html 57 | 220500000000,通化市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/22/2205.html 58 | 220600000000,白山市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/22/2206.html 59 | 220700000000,松原市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/22/2207.html 60 | 220800000000,白城市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/22/2208.html 61 | 222400000000,延边朝鲜族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/22/2224.html 62 | 230100000000,哈尔滨市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/23/2301.html 63 | 230200000000,齐齐哈尔市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/23/2302.html 64 | 230300000000,鸡西市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/23/2303.html 65 | 230400000000,鹤岗市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/23/2304.html 66 | 230500000000,双鸭山市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/23/2305.html 67 | 230600000000,大庆市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/23/2306.html 68 | 230700000000,伊春市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/23/2307.html 69 | 230800000000,佳木斯市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/23/2308.html 70 | 230900000000,七台河市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/23/2309.html 71 | 231000000000,牡丹江市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/23/2310.html 72 | 231100000000,黑河市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/23/2311.html 73 | 231200000000,绥化市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/23/2312.html 74 | 232700000000,大兴安岭地区,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/23/2327.html 75 | 310100000000,市辖区,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/31/3101.html 76 | 320100000000,南京市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/32/3201.html 77 | 320200000000,无锡市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/32/3202.html 78 | 320300000000,徐州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/32/3203.html 79 | 320400000000,常州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/32/3204.html 80 | 320500000000,苏州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/32/3205.html 81 | 320600000000,南通市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/32/3206.html 82 | 320700000000,连云港市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/32/3207.html 83 | 320800000000,淮安市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/32/3208.html 84 | 320900000000,盐城市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/32/3209.html 85 | 321000000000,扬州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/32/3210.html 86 | 321100000000,镇江市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/32/3211.html 87 | 321200000000,泰州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/32/3212.html 88 | 321300000000,宿迁市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/32/3213.html 89 | 330100000000,杭州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/33/3301.html 90 | 330200000000,宁波市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/33/3302.html 91 | 330300000000,温州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/33/3303.html 92 | 330400000000,嘉兴市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/33/3304.html 93 | 330500000000,湖州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/33/3305.html 94 | 330600000000,绍兴市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/33/3306.html 95 | 330700000000,金华市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/33/3307.html 96 | 330800000000,衢州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/33/3308.html 97 | 330900000000,舟山市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/33/3309.html 98 | 331000000000,台州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/33/3310.html 99 | 331100000000,丽水市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/33/3311.html 100 | 340100000000,合肥市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/34/3401.html 101 | 340200000000,芜湖市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/34/3402.html 102 | 340300000000,蚌埠市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/34/3403.html 103 | 340400000000,淮南市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/34/3404.html 104 | 340500000000,马鞍山市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/34/3405.html 105 | 340600000000,淮北市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/34/3406.html 106 | 340700000000,铜陵市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/34/3407.html 107 | 340800000000,安庆市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/34/3408.html 108 | 341000000000,黄山市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/34/3410.html 109 | 341100000000,滁州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/34/3411.html 110 | 341200000000,阜阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/34/3412.html 111 | 341300000000,宿州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/34/3413.html 112 | 341500000000,六安市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/34/3415.html 113 | 341600000000,亳州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/34/3416.html 114 | 341700000000,池州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/34/3417.html 115 | 341800000000,宣城市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/34/3418.html 116 | 350100000000,福州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/35/3501.html 117 | 350200000000,厦门市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/35/3502.html 118 | 350300000000,莆田市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/35/3503.html 119 | 350400000000,三明市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/35/3504.html 120 | 350500000000,泉州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/35/3505.html 121 | 350600000000,漳州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/35/3506.html 122 | 350700000000,南平市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/35/3507.html 123 | 350800000000,龙岩市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/35/3508.html 124 | 350900000000,宁德市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/35/3509.html 125 | 360100000000,南昌市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/36/3601.html 126 | 360200000000,景德镇市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/36/3602.html 127 | 360300000000,萍乡市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/36/3603.html 128 | 360400000000,九江市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/36/3604.html 129 | 360500000000,新余市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/36/3605.html 130 | 360600000000,鹰潭市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/36/3606.html 131 | 360700000000,赣州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/36/3607.html 132 | 360800000000,吉安市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/36/3608.html 133 | 360900000000,宜春市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/36/3609.html 134 | 361000000000,抚州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/36/3610.html 135 | 361100000000,上饶市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/36/3611.html 136 | 370100000000,济南市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/37/3701.html 137 | 370200000000,青岛市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/37/3702.html 138 | 370300000000,淄博市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/37/3703.html 139 | 370400000000,枣庄市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/37/3704.html 140 | 370500000000,东营市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/37/3705.html 141 | 370600000000,烟台市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/37/3706.html 142 | 370700000000,潍坊市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/37/3707.html 143 | 370800000000,济宁市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/37/3708.html 144 | 370900000000,泰安市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/37/3709.html 145 | 371000000000,威海市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/37/3710.html 146 | 371100000000,日照市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/37/3711.html 147 | 371200000000,莱芜市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/37/3712.html 148 | 371300000000,临沂市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/37/3713.html 149 | 371400000000,德州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/37/3714.html 150 | 371500000000,聊城市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/37/3715.html 151 | 371600000000,滨州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/37/3716.html 152 | 371700000000,菏泽市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/37/3717.html 153 | 410100000000,郑州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/41/4101.html 154 | 410200000000,开封市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/41/4102.html 155 | 410300000000,洛阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/41/4103.html 156 | 410400000000,平顶山市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/41/4104.html 157 | 410500000000,安阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/41/4105.html 158 | 410600000000,鹤壁市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/41/4106.html 159 | 410700000000,新乡市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/41/4107.html 160 | 410800000000,焦作市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/41/4108.html 161 | 410900000000,濮阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/41/4109.html 162 | 411000000000,许昌市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/41/4110.html 163 | 411100000000,漯河市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/41/4111.html 164 | 411200000000,三门峡市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/41/4112.html 165 | 411300000000,南阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/41/4113.html 166 | 411400000000,商丘市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/41/4114.html 167 | 411500000000,信阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/41/4115.html 168 | 411600000000,周口市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/41/4116.html 169 | 411700000000,驻马店市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/41/4117.html 170 | 419000000000,省直辖县级行政区划,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/41/4190.html 171 | 420100000000,武汉市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/42/4201.html 172 | 420200000000,黄石市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/42/4202.html 173 | 420300000000,十堰市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/42/4203.html 174 | 420500000000,宜昌市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/42/4205.html 175 | 420600000000,襄阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/42/4206.html 176 | 420700000000,鄂州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/42/4207.html 177 | 420800000000,荆门市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/42/4208.html 178 | 420900000000,孝感市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/42/4209.html 179 | 421000000000,荆州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/42/4210.html 180 | 421100000000,黄冈市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/42/4211.html 181 | 421200000000,咸宁市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/42/4212.html 182 | 421300000000,随州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/42/4213.html 183 | 422800000000,恩施土家族苗族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/42/4228.html 184 | 429000000000,省直辖县级行政区划,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/42/4290.html 185 | 430100000000,长沙市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/43/4301.html 186 | 430200000000,株洲市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/43/4302.html 187 | 430300000000,湘潭市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/43/4303.html 188 | 430400000000,衡阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/43/4304.html 189 | 430500000000,邵阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/43/4305.html 190 | 430600000000,岳阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/43/4306.html 191 | 430700000000,常德市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/43/4307.html 192 | 430800000000,张家界市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/43/4308.html 193 | 430900000000,益阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/43/4309.html 194 | 431000000000,郴州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/43/4310.html 195 | 431100000000,永州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/43/4311.html 196 | 431200000000,怀化市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/43/4312.html 197 | 431300000000,娄底市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/43/4313.html 198 | 433100000000,湘西土家族苗族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/43/4331.html 199 | 440100000000,广州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4401.html 200 | 440200000000,韶关市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4402.html 201 | 440300000000,深圳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4403.html 202 | 440400000000,珠海市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4404.html 203 | 440500000000,汕头市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4405.html 204 | 440600000000,佛山市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4406.html 205 | 440700000000,江门市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4407.html 206 | 440800000000,湛江市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4408.html 207 | 440900000000,茂名市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4409.html 208 | 441200000000,肇庆市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4412.html 209 | 441300000000,惠州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4413.html 210 | 441400000000,梅州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4414.html 211 | 441500000000,汕尾市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4415.html 212 | 441600000000,河源市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4416.html 213 | 441700000000,阳江市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4417.html 214 | 441800000000,清远市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4418.html 215 | 441900000000,东莞市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4419.html 216 | 442000000000,中山市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4420.html 217 | 445100000000,潮州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4451.html 218 | 445200000000,揭阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4452.html 219 | 445300000000,云浮市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44/4453.html 220 | 450100000000,南宁市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/45/4501.html 221 | 450200000000,柳州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/45/4502.html 222 | 450300000000,桂林市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/45/4503.html 223 | 450400000000,梧州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/45/4504.html 224 | 450500000000,北海市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/45/4505.html 225 | 450600000000,防城港市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/45/4506.html 226 | 450700000000,钦州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/45/4507.html 227 | 450800000000,贵港市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/45/4508.html 228 | 450900000000,玉林市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/45/4509.html 229 | 451000000000,百色市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/45/4510.html 230 | 451100000000,贺州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/45/4511.html 231 | 451200000000,河池市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/45/4512.html 232 | 451300000000,来宾市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/45/4513.html 233 | 451400000000,崇左市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/45/4514.html 234 | 460100000000,海口市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/46/4601.html 235 | 460200000000,三亚市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/46/4602.html 236 | 460300000000,三沙市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/46/4603.html 237 | 460400000000,儋州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/46/4604.html 238 | 469000000000,省直辖县级行政区划,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/46/4690.html 239 | 500100000000,市辖区,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/50/5001.html 240 | 500200000000,县,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/50/5002.html 241 | 510100000000,成都市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5101.html 242 | 510300000000,自贡市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5103.html 243 | 510400000000,攀枝花市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5104.html 244 | 510500000000,泸州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5105.html 245 | 510600000000,德阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5106.html 246 | 510700000000,绵阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5107.html 247 | 510800000000,广元市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5108.html 248 | 510900000000,遂宁市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5109.html 249 | 511000000000,内江市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5110.html 250 | 511100000000,乐山市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5111.html 251 | 511300000000,南充市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5113.html 252 | 511400000000,眉山市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5114.html 253 | 511500000000,宜宾市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5115.html 254 | 511600000000,广安市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5116.html 255 | 511700000000,达州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5117.html 256 | 511800000000,雅安市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5118.html 257 | 511900000000,巴中市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5119.html 258 | 512000000000,资阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5120.html 259 | 513200000000,阿坝藏族羌族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5132.html 260 | 513300000000,甘孜藏族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5133.html 261 | 513400000000,凉山彝族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51/5134.html 262 | 520100000000,贵阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/52/5201.html 263 | 520200000000,六盘水市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/52/5202.html 264 | 520300000000,遵义市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/52/5203.html 265 | 520400000000,安顺市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/52/5204.html 266 | 520500000000,毕节市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/52/5205.html 267 | 520600000000,铜仁市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/52/5206.html 268 | 522300000000,黔西南布依族苗族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/52/5223.html 269 | 522600000000,黔东南苗族侗族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/52/5226.html 270 | 522700000000,黔南布依族苗族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/52/5227.html 271 | 530100000000,昆明市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/53/5301.html 272 | 530300000000,曲靖市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/53/5303.html 273 | 530400000000,玉溪市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/53/5304.html 274 | 530500000000,保山市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/53/5305.html 275 | 530600000000,昭通市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/53/5306.html 276 | 530700000000,丽江市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/53/5307.html 277 | 530800000000,普洱市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/53/5308.html 278 | 530900000000,临沧市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/53/5309.html 279 | 532300000000,楚雄彝族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/53/5323.html 280 | 532500000000,红河哈尼族彝族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/53/5325.html 281 | 532600000000,文山壮族苗族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/53/5326.html 282 | 532800000000,西双版纳傣族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/53/5328.html 283 | 532900000000,大理白族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/53/5329.html 284 | 533100000000,德宏傣族景颇族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/53/5331.html 285 | 533300000000,怒江傈僳族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/53/5333.html 286 | 533400000000,迪庆藏族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/53/5334.html 287 | 540100000000,拉萨市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/54/5401.html 288 | 540200000000,日喀则市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/54/5402.html 289 | 540300000000,昌都市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/54/5403.html 290 | 540400000000,林芝市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/54/5404.html 291 | 540500000000,山南市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/54/5405.html 292 | 542400000000,那曲地区,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/54/5424.html 293 | 542500000000,阿里地区,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/54/5425.html 294 | 610100000000,西安市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/61/6101.html 295 | 610200000000,铜川市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/61/6102.html 296 | 610300000000,宝鸡市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/61/6103.html 297 | 610400000000,咸阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/61/6104.html 298 | 610500000000,渭南市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/61/6105.html 299 | 610600000000,延安市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/61/6106.html 300 | 610700000000,汉中市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/61/6107.html 301 | 610800000000,榆林市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/61/6108.html 302 | 610900000000,安康市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/61/6109.html 303 | 611000000000,商洛市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/61/6110.html 304 | 620100000000,兰州市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6201.html 305 | 620200000000,嘉峪关市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6202.html 306 | 620300000000,金昌市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6203.html 307 | 620400000000,白银市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6204.html 308 | 620500000000,天水市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6205.html 309 | 620600000000,武威市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6206.html 310 | 620700000000,张掖市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6207.html 311 | 620800000000,平凉市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6208.html 312 | 620900000000,酒泉市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6209.html 313 | 621000000000,庆阳市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6210.html 314 | 621100000000,定西市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6211.html 315 | 621200000000,陇南市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6212.html 316 | 622900000000,临夏回族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6229.html 317 | 623000000000,甘南藏族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6230.html 318 | 630100000000,西宁市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/63/6301.html 319 | 630200000000,海东市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/63/6302.html 320 | 632200000000,海北藏族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/63/6322.html 321 | 632300000000,黄南藏族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/63/6323.html 322 | 632500000000,海南藏族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/63/6325.html 323 | 632600000000,果洛藏族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/63/6326.html 324 | 632700000000,玉树藏族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/63/6327.html 325 | 632800000000,海西蒙古族藏族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/63/6328.html 326 | 640100000000,银川市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/64/6401.html 327 | 640200000000,石嘴山市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/64/6402.html 328 | 640300000000,吴忠市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/64/6403.html 329 | 640400000000,固原市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/64/6404.html 330 | 640500000000,中卫市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/64/6405.html 331 | 650100000000,乌鲁木齐市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/65/6501.html 332 | 650200000000,克拉玛依市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/65/6502.html 333 | 650400000000,吐鲁番市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/65/6504.html 334 | 650500000000,哈密市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/65/6505.html 335 | 652300000000,昌吉回族自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/65/6523.html 336 | 652700000000,博尔塔拉蒙古自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/65/6527.html 337 | 652800000000,巴音郭楞蒙古自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/65/6528.html 338 | 652900000000,阿克苏地区,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/65/6529.html 339 | 653000000000,克孜勒苏柯尔克孜自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/65/6530.html 340 | 653100000000,喀什地区,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/65/6531.html 341 | 653200000000,和田地区,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/65/6532.html 342 | 654000000000,伊犁哈萨克自治州,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/65/6540.html 343 | 654200000000,塔城地区,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/65/6542.html 344 | 654300000000,阿勒泰地区,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/65/6543.html 345 | 659000000000,自治区直辖县级行政区划,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/65/6590.html 346 | -------------------------------------------------------------------------------- /data/province.csv: -------------------------------------------------------------------------------- 1 | name,link 2 | 北京市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/11.html 3 | 天津市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/12.html 4 | 河北省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/13.html 5 | 山西省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/14.html 6 | 内蒙古自治区,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/15.html 7 | 辽宁省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/21.html 8 | 吉林省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/22.html 9 | 黑龙江省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/23.html 10 | 上海市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/31.html 11 | 江苏省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/32.html 12 | 浙江省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/33.html 13 | 安徽省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/34.html 14 | 福建省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/35.html 15 | 江西省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/36.html 16 | 山东省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/37.html 17 | 河南省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/41.html 18 | 湖北省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/42.html 19 | 湖南省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/43.html 20 | 广东省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/44.html 21 | 广西壮族自治区,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/45.html 22 | 海南省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/46.html 23 | 重庆市,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/50.html 24 | 四川省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/51.html 25 | 贵州省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/52.html 26 | 云南省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/53.html 27 | 西藏自治区,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/54.html 28 | 陕西省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/61.html 29 | 甘肃省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62.html 30 | 青海省,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/63.html 31 | 宁夏回族自治区,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/64.html 32 | 新疆维吾尔自治区,http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/65.html 33 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | fake_useragent==0.1.11 2 | pandas==0.22.0 3 | requests==2.20.0 4 | lxml==4.2.5 5 | -------------------------------------------------------------------------------- /合并多个csv文件.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # 导入所需的包 4 | import os 5 | import pandas as pd 6 | import glob 7 | 8 | # 合并多个csv文件 9 | csv_list = glob.glob('*.csv') #查看同文件夹下的csv文件数 10 | print(u'共发现%s个CSV文件'% len(csv_list)) 11 | print(u'正在处理............') 12 | for i in csv_list: #循环读取同文件夹下的csv文件 13 | fr = open(i,'rb').read() 14 | with open('result.csv','ab') as f: #将结果保存为result.csv 15 | f.write(fr) 16 | print(u'合并完毕!') 17 | 18 | # 去重函数 19 | # 这个函数将重复的内容去掉,主要是去表头。 20 | df = pd.read_csv("result.csv",header=0) 21 | datalist = df.drop_duplicates(keep = False) 22 | 23 | # 排序函数 24 | datalist_sorted = datalist.sort_values(by = ['code']) #按1列进行升序排序 25 | 26 | # 结果写入csv文件 27 | datalist_sorted.to_csv("village_all.csv", sep = ',', header = True,index = False) 28 | 29 | --------------------------------------------------------------------------------