zoukankan      html  css  js  c++  java
  • 下载图片

    import requests
    from hashlib import md5
    import threading
    import time
    def down_load_pic(url):
    req= requests.get(url)
    m = md5(url.encode())
    with open(m.hexdigest() + '.png', 'wb') as fw:
    fw.write(req.content)

    url_list = ['http://www.nnzhp.cn/wp-content/uploads/2019/10/f410afea8b23fa401505a1449a41a133.png',
    'http://www.nnzhp.cn/wp-content/uploads/2019/11/481b5135e75c764b32b224c5650a8df5.png',
    'http://www.nnzhp.cn/wp-content/uploads/2019/11/b23755cdea210cfec903333c5cce6895.png',
    'http://www.nnzhp.cn/wp-content/uploads/2019/11/542824dde1dbd29ec61ad5ea867ef245.png']

    start_time = time.time()
    for url in url_list:
    t = threading.Thread(target=down_load_pic,args=(url,))
    t.start()
    while threading.activeCount()!=1:
    pass
    end_time = time.time()
    print(end_time-start_time)
  • 相关阅读:
    php设计模式 — 简单工厂模式(静态工厂方法模式)
    Vue-Router
    各种选项卡
    jq动画
    如何使用swiper写轮播
    Gulp代码压缩
    闭包
    jquery.validation校验
    grunt-js文件压缩
    CSS
  • 原文地址:https://www.cnblogs.com/lapt/p/11893254.html
Copyright © 2011-2022 走看看