标签:当前目录 new fir lib 记录 module 添加 python start
#建立名为tuto的项目 scrapy startproject tuto
cd tuto
#minyan任务名;后面是任务对应的域名 scrapy genspider minyan quotes.toscrape.com
E:\a\scrapy_test>scrapy startproject tuto New Scrapy project ‘tuto‘, using template directory ‘c:\python\python37\lib\site -packages\scrapy\templates\project‘, created in: E:\a\scrapy_test\tuto You can start your first spider with: cd tuto scrapy genspider example example.com E:\a\scrapy_test>cd tuto E:\a\scrapy_test\tuto>scrapy genspider minyan quotes.toscrape.com Created spider ‘minyan‘ using template ‘basic‘ in module: tuto.spiders.minyan E:\a\scrapy_test\tuto>
4.pycharm打开项目,建立用于调试的文件:main.py
用到的函数解析:https://www.cnblogs.com/chenxi188/p/10876690.html
main.py:
# -*- coding: utf-8 -*- __author__=‘pasaulis‘ import sys,os from scrapy.cmdline import execute #获取到当前目录,添加到环境变量,方便运行cmd不必再去找目录 #.append()添加到环境变量;.dirname()输出不含文件名的路径;.abspath(__file__)得到当前文件的绝对路径 sys.path.append(os.path.dirname(os.path.abspath(__file__))) #调用命令运行爬虫scrapy crawl 爬虫名minyan.py中(name的值) execute(["scrapy","crawl","minyan"])
标签:当前目录 new fir lib 记录 module 添加 python start
原文地址:https://www.cnblogs.com/chenxi188/p/10876901.html