3 Star 2 Fork 0

天涯明月笙/ArticleSpider

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.py 822 Bytes
一键复制 编辑 原始数据 按行查看 历史
天涯明月笙 提交于 2018-01-30 04:41 . 2018-2 最新可用代码
# encoding: utf-8
__author__ = 'mtianyan'
__date__ = '2018/1/17 0017 19:50'
from scrapy.cmdline import execute
import sys
import os
# 将项目根目录加入系统环境变量中。
# os.path.abspath(__file__)为当前文件所在绝对路径
# os.path.dirname() 获取文件的父目录。
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
print(os.path.abspath(__file__))
# D:\CodeSpace\PythonProject\ArticleSpider\main.py
print(os.path.dirname(os.path.abspath(__file__)))
# D:\CodeSpace\PythonProject\ArticleSpider
# 调用execute函数执行scrapy命令,相当于在控制台cmd输入该命令
# 可以传递一个数组参数进来:
# execute(["scrapy", "crawl" , "jobbole"])
execute(["scrapy", "crawl" , "zhihu"])
# execute(["scrapy", "crawl" , "lagou"])
# execute(["scrapy", "crawl" , "fang"])
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/mtianyan/ArticleSpider.git
git@gitee.com:mtianyan/ArticleSpider.git
mtianyan
ArticleSpider
ArticleSpider
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385