2018-12-29
- 安装scrapy
1.1 使用pycharm新建虚拟环境(python_scrapy)
1.2 安装scrapy之前,先下载安装twisted(注意对应自己的python、操作系统版本!!),不安装twisted,直接安装scrapy会报错
下载twisted包
# 使用pip install (下载的twisted文件位置)安装twisted

1.3 安装scrapy
pip install scrapy


- 在pycharm中使用scrapy框架
2.1 创建爬虫项目,这里使用crawl模板,可以生成更接近我们想要的此次爬虫项目的初始版本。
# 创建项目名称
scrapy startproject <项目名称>
# cd到项目目录下,生成爬虫文件
scrapy genspider 模板名称 爬取的网址 --template=要使用的模板

设置settings文件,防止被但爬虫机制发现,导致封掉IP

网友评论