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

scrapy 抓取信息, time.sleep()问题

  •  
  •   appleaa · Oct 26, 2015 · 6135 views
    This topic created in 3862 days ago, the information mentioned may be changed or developed.
    使用 scrapy 抓取 http://www.cnbeta.com/topics/9.htm ,先抓取文章标题, yield Item 存储,再根据 link 抓内容, yield content, 然后 time.sleep(1200)。但是 yield content 处理时间比较长, time.sleep 会是全局停止,导致好长时间抓取不到 content ,请教大家怎么做?
    7 replies    2018-07-06 18:41:40 +08:00
    pango
        1
    pango  
       Oct 26, 2015
    为什么要 sleep ? scrapy 不是可以自己控制并发数吗?
    appleaa
        2
    appleaa  
    OP
       Oct 26, 2015
    @pango 我是循环抓取, sleep 20 分钟后看这个页面有没有新内容,不是并发问题
    sometimesna1ve
        3
    sometimesna1ve  
       Oct 26, 2015
    @appleaa 为什么不定时 20 分钟后重新跑一次抓取程序?
    appleaa
        4
    appleaa  
    OP
       Oct 26, 2015
    @rockivy 程序框架都是这样定的,以前没发现这个问题
    ahxxm
        5
    ahxxm  
       Oct 27, 2015
    "*/20 * * * * timeout=600 scrapy crawl cnbeta"加进 crontab 就行了, 20 分钟来一发, 10 分钟没跑完自动干掉进程
    lev
        6
    lev  
       Oct 28, 2015
    可以设置全局参数 DOWNLOAD_DELAY http://doc.scrapy.org/en/latest/topics/settings.html
    kmz
        7
    kmz  
       Jul 6, 2018
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   951 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 66ms · UTC 19:19 · PVG 03:19 · LAX 12:19 · JFK 15:19
    ♥ Do have faith in what you're doing.