
页面地址:http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2021/11/01/01/110101001.html 最近需要使用最新的行政区划信息,虽然统计局公开了相关的数据,但是并没有提供数据文件。于是,就写了个爬虫把所有的数据爬取了一遍。生成的默认数据格式为json,另外提供了一个工具来把json转成csv。

页面地址:http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2021/11/01/01/110101001.html 最近需要使用最新的行政区划信息,虽然统计局公开了相关的数据,但是并没有提供数据文件。于是,就写了个爬虫把所有的数据爬取了一遍。生成的默认数据格式为json,另外提供了一个工具来把json转成csv。
常用的代码保护不外乎下面几种方法:
发行 .pyc 文件 代码混淆 使用 py2exe 使用 Cython
django发布的需要以服务运行,通过其他的几种方法来实现保护,都不太现实。所以发布可以通过cython的方式实现。
1. 安装cython
pip3 install cython
2.在项目目录创建setup.py 编辑内容如下,其中“app/file1.py”是你所要打包的py文件名,这儿需要把app下所有的py文件都添加进来(当然也可以添加部分)
from distutils.core import setup
from Cython.Build import cythonize
fileSet = set()
fileSet.add("UserBase/models.py")
fileSet.add("UserBase/views.py")
setup(
ext_modules=cythonize(fileSet)
)
我增加了几个重要的参数:
****************************************************************************************************
USAGE:
spider -h <help> -a <all> -q <search>
Arguments:
-a <download all site images>
-q <query the image with keywords>
-h <display help text, just this>
Option Arguments:
-p <image download path>
-r <random index category list> (该参数会重新排列分类列表,可以开启多个进程同时进行爬取)
-c <single category url> (支持单分类爬取,如果只想爬取某一个分类请使用该参数)
-s <site url eg: http://www.xiurenji.vip (no last backslash "/")>
****************************************************************************************************
我增加了几个重要的参数:
****************************************************************************************************
USAGE:
spider -h <help> -a <all> -q <search>
Arguments:
-a <download all site images>
-q <query the image with keywords>
-h <display help text, just this>
Option Arguments:
-p <image download path>
-r <random index category list> (该参数会重新排列分类列表,可以开启多个进程同时进行爬取)
-c <single category url> (支持单分类爬取,如果只想爬取某一个分类请使用该参数)
-s <site url eg: http://www.xiurenji.vip (no last backslash "/")>
****************************************************************************************************
***********************************************************************************
参数说明:
/Users/zhongming/PycharmProjects/meitulu/dist/xiurenji/xiurenji
USAGE:
spider -h <help> -a <all> -q <search>
Arguments:
-a <download all site images>
-q <query the image with keywords>
-h <display help text, just this>
Option Arguments:
-p <image download path>
-s <site url eg: http://www.xiurenji.vip (no last backslash "/")>
***********************************************************************************