Scrapy 学习笔记(一)

来源:互联网 发布:美工与设计师的区别 编辑:程序博客网 时间:2024/05/23 00:27

0x00 Scarpy的安装

scrapy最简单的安装方法:

pip install Scrapy

pip的安装方法:
https://pip.pypa.io/en/latest/installing.html

下载源代码安装
http://scrapy.org/download/

安装方法:

sudo python setup.py install

0x01 创建第一个爬虫

  • 创建project
scrapy startproject myproject
  • 创建spider
scrapy genspider -l scrapy genspider [-t template] <name> <domain>scrapy genspider -t basic myspiderbasic douban.com
  • 使用spider 进行爬取
scrapy crawl myspider
  • 列出所有的spider
scrapy list
  • 编辑spider
scrapy edit <spider>
  • 使用spider进行爬取
scrapy crawl <spider>
  • 运行contract检查
scrapy check [-l] <spider>

参考:
http://scrapy-chs.readthedocs.org/zh_CN/latest/intro/overview.html

0 0