Python3 scrapy 新手命令

基本命令

建立项目
scrapy startproject projectname #在CMD命令框内执行,路径是你需要保存的位置

建立爬虫
cd projectname  #在CMD命令框内执行,目的是建立py文件,必须cd进入到爬虫项目文件夹才可以用
scrapy genspider spidername xxx.com #名字是自己取得,后面是爬取得初始网址,这一步可以在后续修改

调试爬虫
scrapy shell 网址  #网址输入需要调试的网址,scrapy会自动获取页面用来调试,自动获得一个response的返回值就是页面代码
运行爬虫 
scrapy crawl spidername #运行爬虫,不保存信息
scrapy crawl spidername -o quotes.json #常用这种
scrapy crawl spidername -o quotes.jl
scrapy crawl spidername -o quotes.csv
scrapy crawl spidername -o quotes.xml #网页源代码格式

停止爬虫
CTRL C


原文地址:https://www.cnblogs.com/passagain/p/10765626.html