推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
zcsnbb
V2EX  ›  Python

关于 scrapy 运行机制

  •  
  •   zcsnbb · Oct 26, 2018 · 2561 views
    This topic created in 2834 days ago, the information mentioned may be changed or developed.

    在使用 scrapy 框架编写爬虫时, 可以同时编写多个爬虫,运行时只需要输入相对应的爬虫名即可运行该爬虫而不会影响到去他的爬虫,请问这是如何实现的,在哪里可以看相关文档呢

    8 replies    2018-10-26 15:12:19 +08:00
    nicevar
        1
    nicevar  
       Oct 26, 2018
    直接点就看源码,看不懂就用搜索引擎,有很多人写过相关文章
    zcsnbb
        2
    zcsnbb  
    OP
       Oct 26, 2018
    @nicevar 源码的话没有找到怎么去实现的,搜索的结果大多都是怎么使用 scrapy 去创建爬虫,并没有对框架的具体的解读,
    sunwei0325
        3
    sunwei0325  
       Oct 26, 2018
    twisted 实现的
    zcsnbb
        4
    zcsnbb  
    OP
       Oct 26, 2018
    @sunwei0325 您好 能具体说一下吗,或者说哪里有相关的文档或者参考资料呢,twisted 不是一个异步网络框架吗,不是为了提升爬取速度的吗,十分感谢
    binux
        5
    binux  
       Oct 26, 2018
    你为什么会觉得会影响到“去他的爬虫”?
    zcsnbb
        6
    zcsnbb  
    OP
       Oct 26, 2018
    @binux 其他的 sorry 手残打错了
    owenliang
        7
    owenliang  
       Oct 26, 2018   ❤️ 2
    读 scrapy.cfg 的 settings 可以找到 settings.py ,动态__import__给 load 起来,读里面的 SPIDER_MODULES 找到爬虫 spiders 包。

    在这个包里每个.py 文件都是一个 module,可以动态__import__给 load 起来,找到 module 里继承了 scrapy.spiders.Spider 的 class,看一下这个 class 的__dict__['name']叫什么,是不是你启动传的那个。

    没啥东西,就是动态__import__ module 啊,目录遍历啊,__dict__动态访问对象属性啊。
    zcsnbb
        8
    zcsnbb  
    OP
       Oct 26, 2018
    @owenliang 十分感谢 我研究一下
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3120 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 12:27 · PVG 20:27 · LAX 05:27 · JFK 08:27
    ♥ Do have faith in what you're doing.