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
SpiderXiantang
V2EX  ›  Python

requests 在并发太高的情况下 报错

  •  
  •   SpiderXiantang ·
    xiantang · 2018-08-03 14:25:40 +08:00 · 3399 次点击
    这是一个创建于 2064 天前的主题,其中的信息可能已经有所发展或是发生改变。

    也就开了 32 个线程这样,爬一会就疯狂报错 然后把并发改为 10 之后就可以正常爬了

    requests.exceptions.SSLError: EOF occurred in violation of protocol (_ssl.c:645)
    

    还有个问题:爬虫插入 mysql 的策略是什么? 一定数量批量插 还是一条一条插 感觉一条条插在高并发的情况下十分不稳定

    8 条回复    2018-08-04 15:44:30 +08:00
    xxxy
        1
    xxxy  
       2018-08-03 15:30:14 +08:00
    貌似是 openssl 的限制?
    lhy360121
        2
    lhy360121  
       2018-08-03 15:36:59 +08:00
    批量插
    lllllllllllllll
        3
    lllllllllllllll  
       2018-08-03 16:07:31 +08:00
    pip install 'requests[security]'
    nu11001
        4
    nu11001  
       2018-08-03 16:19:43 +08:00
    试试异步 aiohttp
    SpiderXiantang
        5
    SpiderXiantang  
    OP
       2018-08-03 17:10:05 +08:00
    @xxxy 后来我发现 我开并发为 10 的情况下也会报错
    SpiderXiantang
        6
    SpiderXiantang  
    OP
       2018-08-03 17:10:14 +08:00
    @lllllllllllllll 我试试
    luguhu
        7
    luguhu  
       2018-08-03 21:30:57 +08:00 via Android
    @SpiderXiantang 你好,我也遇到这个问题。请问解决了吗?
    SpiderXiantang
        8
    SpiderXiantang  
    OP
       2018-08-04 15:44:30 +08:00
    @luguhu 安装 requets[security]
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   976 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:55 · PVG 05:55 · LAX 14:55 · JFK 17:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.