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

Python3 爬虫请教

  •  
  •   wanchenyi · Jun 27, 2024 · 3759 views
    This topic created in 678 days ago, the information mentioned may be changed or developed.

    各位佬,请教一个问题,我写了一个下载 ts 视频的爬虫,在电脑上,开了 30 个线程去下载,就能达到 6MB/s ,现在我把这个脚本放到斐讯 N1 盒子的 docker 容器上去下载,把线程修改成了 4 个,结果下载就很慢,有什么办法能提升呢,想请各位指点哈,斐讯盒子接了移动硬盘。感谢各位指点。这里可能是线程的原因,我想知道的是如何提升下载速度,感谢各位。

    10 replies    2024-07-03 21:24:07 +08:00
    yzding
        1
    yzding  
       Jun 27, 2024 via iPhone
    你看看你接硬盘写入速度是多少
    lulinihao
        2
    lulinihao  
       Jun 27, 2024
    电脑 4 线程速率是多少?
    Mrrobot233
        3
    Mrrobot233  
       Jun 28, 2024 via Android
    b 站搜下携程相关的内容,具体的我也忘了,21 年写过,现在 python 不知道咋样了
    su14772
        4
    su14772  
       Jun 28, 2024
    python 非最新版本的话,多线程有 GIL 锁,用不了多核心,意义不大。下载视频的爬虫,时长可能会很长,异步协程可以加速,但是应该也加不了多少。试试多进程+协程吧
    gray0
        5
    gray0  
       Jun 28, 2024
    +线程 = +下载速度,这个不相等吧 ,莫名其妙啊老哥
    下载视频可以试试开源项目
    https://github.com/soimort/you-get
    EndlessMemory
        6
    EndlessMemory  
       Jun 28, 2024
    也开 30 个线程
    xxxccc
        7
    xxxccc  
       Jun 28, 2024
    @su14772 跟 GIL 锁没有任何关系,下载本身就是 io 多的情况,这个情况下 GIL 不会对并发有影响的。
    yagamil
        8
    yagamil  
       Jun 28, 2024
    斐讯的 N1 盒子 usb2.0 质量不行。
    lzZzeucJri6FcR0o
        9
    lzZzeucJri6FcR0o  
       Jun 28, 2024
    @su14772 #4 大错特错。。。爬虫用的就是多线程,和 GIL 锁没关系,多核性能用在 cpu 密集计算
    atx
        10
    atx  
       Jul 3, 2024
    换个思路呢,python 只负责解析下载链接,调用 aria2 下载,轻松跑满带宽。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5554 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 61ms · UTC 01:17 · PVG 09:17 · LAX 18:17 · JFK 21:17
    ♥ Do have faith in what you're doing.