基本信息
源码名称:百度图库爬虫
源码大小:3.25KB
文件格式:.py
开发语言:Python
更新时间:2021-10-05
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 3 元 
   源码介绍
输入要下载的图片关键词,图片自动批量下载到本地


def dowmloadPicture(html, keyword):
    global num
    # t =0
    pic_url = re.findall('"objURL":"(.*?)",', html, re.S)  # 先利用正则表达式找到图片url
    for each in pic_url:
        print('正在下载第' str(num 1) '张图片,图片地址:' str(each))
        try:
            if each is not None:
                pic = requests.get(each, timeout=7)
            else:
                continue
        except BaseException:
            print('错误,当前图片无法下载')
            continue
        else:
            string = file r'\\' keyword '_' str(num 1) '.jpg'
            fp = open(string, 'wb')
            fp.write(pic.content)
            fp.close()
            num = 1
        if num >= numPicture:
            return