关于 scrapy 处理批量 url - V2EX
推荐学习书目
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
akmonde

关于 scrapy 处理批量 url

  •  
  •   akmonde May 3, 2018 4471 views
    This topic created in 2936 days ago, the information mentioned may be changed or developed.

    RT,我这边有需求处理一批 URL 入口,其中可能会定制传入相应的参数,形式大概类似于:

    execute(['scrapy', 'crawl', 'woshiscrapy', '-a', 'para=%s' % para) 

    试过多进程和多线程,完全不适配,似乎异步 twisted 好像需要其他法子解决速度问题。

    本来放弃速度,准备直接 for 循环传入,结果发现调用 execute 执行 scrapy,爬完了第一个 url,就直接退出了主程序。

    很无奈,求各位大佬给点具体的方案建议,小弟有点没招了。

    Supplement 1    May 4, 2018
    @Leigg @arithboy @Mitt @lins05
    感谢以上各位大佬,最后采用了 scrapy_redis,不知道大家知道如何让 scrapy 爬行某个站完成后,发出信号或者做出其他动作。
    另外,我这边执行代码后,调用的原生 scrapy 会直接爬行结束,没法运行后面的代码。
    使用 scrapy_redis 则会直接等待监听,但我不知道在哪儿发出爬行完毕的信号,不然我没法去适时 push 下一个 url。
    不知道哪位大佬知道这个,能解答下?