创建工程:scrapy startproject news163Program
创建爬虫模板:scrapy genspider movie ent.163.com/movie
就会在spiders目录下生成movie文件:
启动运行:在工程根目录执行 scrapy crawl movie
或者写成代码执行:
from scrapy import cmdline
import os
#cmd的多个只运行第一个
cmdline.execute('scrapy crawl movie--nolog'.split())
cmdline.execute('scrapy crawl movie'.split())
#os的可以后台运行
os.system("scrapy crawl movie--nolog")