##服务器系统centos 7.2 安装方法
pip install scrapy
遇到问题
build/temp.linux-x86_64-2.7/_openssl.c:12:24: fatal error: pyconfig.h: No such file or directory
# include <pyconfig.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
https://github.com/Azure/blobxfer/issues/14
sudo yum install -y gcc openssl-devel libffi-devel python-devel
爬虫框架生成命令
//创建一个爬虫项目
scrapy startproject Test
//进入爬虫项目
cd Test/
创建一个新的spider:
scrapy genspider test test.com
爬虫执行命令
scrapy crawl test -o a.json
//后台执行,输出日志和报错日志
(scrapy crawl test --logfile=49.log 2>&1 > 49.out -o 20170629_49.json & )
查看
//
tail -f 49.log
//行数查看
wc -l c.json
tail -f 49.log
//查看有多少错误
sed -n '/error/p' 49.log | wc -l
查看文件大小
ls -lh
查看当前目录所有文件文件夹大小
du -sh *
查看磁盘
df -h
查看进程
ps -ef | grep hbqc
ps -ef | grep scrapy
参考 https://scrapy.org/