scrapy安装

1.安装Python
安装完了记得配置环境,将python目录和python目录下的Scripts目录添加到系统环境变量的Path里。在cmd中输入python如果出现版本信息说明配置完毕

2.安装lxml
lxml是一种使用 Python 编写的库,可以迅速、灵活地处理 XML。网址https://pypi.python.org/pypi/lxml/3.3.1选择对应的Python版本安装。

3.安装zope.interface
直接使用pip命令下载

4.安装Twisted
Twisted是用Python实现的基于事件驱动的网络引擎框架,可以直接pip安装
5.安装pyOpenSSL
pyOpenSSL是Python的OpenSSL接口,直接pip安装
6.安装win32py
下载地址:https://sourceforge.net/projects/pywin32/files/pywin32/Build%20220/,这里特别注意pywin必须与python版本对应,python -v查看python版本,py3.6 win32版本只能用pywin32  3.6 32位的安装包

7.最后直接pip install scrapy,完成安装

scrapy常用命令

scrapy startproject tutorial

scrapy list列出当前目录下可用的spider

scrapy crawl <spider> 运行spider

scrapy shell url 以给定的url进入shell环境

scrapy genspider <name> <domain>

 

scrapy.cfg项目的配置文件

items.py 容器,配置需要采集的字段,相当于是一个dict

piplines 管道,保存数据

middlewares 中间件,对爬虫前后座处理,比如修改headers url过滤器等

spiders 存放spider

原文地址:https://www.cnblogs.com/lajiao/p/7835424.html