V2EX = way to explore
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
warcraft1236
V2EX  ›  Python

scrapy 好像会丢任务

  •  
  •   warcraft1236 · 2020-03-04 16:44:09 +08:00 · 973 次点击
    这是一个创建于 1678 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    前提是用户比较多,每个用户上传的视频也不少,并且下载我是放到 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 的大佬帮忙解惑

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5562 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 02:53 · PVG 10:53 · LAX 19:53 · JFK 22:53
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.