V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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
frank065
V2EX  ›  Python

关于使用协程(asyncio+aiohttp)爬虫的疑惑

  •  
  •   frank065 · May 22, 2018 · 2882 views
    This topic created in 2896 days ago, the information mentioned may be changed or developed.
    由于需要爬取大量数据,所以采用 代理+协程(asyncio+aiohttp) 的方式爬虫获取数据。爬的时候有两点疑惑:
    1. 协程的数量有上限吗?我已经把协程数量调到 300 了,但是服务器内存也没有显著增高。大家一般设置多少个协程爬取数据?(被爬的网站是个常用的大厂,肯定不会被我搞崩掉。我知道不节制的爬虫是不道德的,只是好奇协程数量可以到多大)
    2. 爬虫的速度还不错,但是在总是会在协程结束前的最后几个待爬取网页卡住等很长时间才能抓到,这种情况正常吗?
    3 replies    2018-05-30 22:33:43 +08:00
    lieh222
        1
    lieh222  
       May 23, 2018
    内存开销主要就是 response 和 socket 吧,response 大小不确定,socket 估计 1G 内存能开将近 100 万个吧
    wwwd0g
        2
    wwwd0g  
       May 25, 2018
    超时分链接超时和读取超时,有的网站你访问的时候直接给你一个超长时间的读取...
    rim99
        3
    rim99  
       May 30, 2018 via iPhone
    协程的开销是函数级的,很小
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   6086 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 50ms · UTC 02:07 · PVG 10:07 · LAX 19:07 · JFK 22:07
    ♥ Do have faith in what you're doing.