推荐学习书目
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
daiqiangbudainiu
V2EX  ›  Python

scrapy 好像会丢任务

  •  
  •   daiqiangbudainiu · Mar 4, 2020 · 1348 views
    This topic created in 2277 days ago, the information mentioned may be changed or developed.

    我的需求是这样的,根据一定规则爬取一个视频网站上用户上传的视频,并且将视频下载回来

    前提是用户比较多,每个用户上传的视频也不少,并且下载我是放到 pipeline 中,用 requests 请求 aria2 rpc 接口去下载,因为 scrapy 本身的 filespipeline 会把视频请求的 response 都加载到内存中,这样内存占用太大了

    我运行这个爬虫的时候,发现一个问题

    如果我关掉下载 pipeline,那么爬取的视频数量是对的

    如果打开下载 pipeline,那么爬取的视频数量会少

    我的 pipeline 大概逻辑是

    while 1:
         check aria2 正在下载的任务数量
         if <10:
              break
         sleep 30s
    
    给 aria2 发送下载任务
    

    所以有时候一个 pipeline 任务可能等待时间比较长

    目前猜测是不是因为执行 pipeline 时间比较长,然后 scrapy 有什么超时的限制,一个 yield scray.request() 长时间不执行就丢弃了

    有没有了解 scrapy 的大佬帮忙解惑

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   842 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 21:08 · PVG 05:08 · LAX 14:08 · JFK 17:08
    ♥ Do have faith in what you're doing.