python实现通过URL下载图片到本地服务器
import os
import urllib.request
image_url = 'http://img.jingtuitui.com/759fa20190115144450401.jpg'
file_path = 'C:/python-pro/mall_splier'
# file_name =
image_url
try:
if not os.path.exists(file_path):
os.makedirs(file_path) #如果没有这个path则直接创建
file_suffix =
os.path.splitext(image_url)[1]
print(file_suffix)
filename = '{}{}'.format(file_path, file_suffix) 拼接文件名。
print(filename)
urllib.request.urlretrieve(image_url, filename=filename),利用urllib.request.urltrieve方法下载图片
print(11111)
except IOError as e:
print(1, e)
except Exception as e:
print(2, e)
python实现通过URL下载图片到本地服务器的更多相关文章
- QT通过url下载图片到本地
/* strUrl:下载图片时需要的url strFilePath:下载图片的位置(/home/XXX/YYY.png) */ void ThorPromote::downloadFileFromUr ...
- 根据URL下载图片到本地
/// <summary> /// 下载图片 /// </summary> /// <param name="picUrl">图片Http地址& ...
- 利用Python实现从百度下载图片到本地磁盘
import urllib.request import os import re url=r'http://image.baidu.com/search/index?tn=baiduimage&am ...
- 从url下载图片--java与python实现方式比较
从url下载图片--java与python实现方式比较 博客分类: 技术笔记小点滴 javapython图片下载 一.java的实现方式 首先读取图片 //方式一:直接根据url读取图片 priva ...
- JAVA 通过url下载图片保存到本地
//java 通过url下载图片保存到本地 public static void download(String urlString, int i) throws Exception { // 构造U ...
- java根据图片的url地址下载图片到本地
package com.daojia.haobo.aicircle.util; import sun.misc.BASE64Encoder; import java.io.*; import java ...
- php下载图片到本地
写了一天,就写了这么点代码,凑合用吧. #saveImage.php<?php /** * 图片下载方法,提供两种图片保存方式: * 1.按照图片自带的名称保存 * 2.按照自定义文件名保存 * ...
- 通过HttpURLConnection下载图片到本地--下载附件
一.背景说明 现在我做的系统中,需要有一个下载附件的功能,其实就是下载图片到本地中.相应的图片保存在多媒体系统中,我们只能拿到它的资源地址(url),而不是真实的文件. 这里记录的是下载单个图片.下篇 ...
- C++根据图片url下载图片
需要使用到URLDownloadToFile()函数,该函数在头文件<urlmon.h>中声明. URLDownloadToFile()函数的定义如下: HRESULT URLDownlo ...
随机推荐
- C++ STL (基础)
STL是什么(STL简介) 本节主要讲述 STL 历史.STL 组件.STL 基本结构以及 STL 编程概述.STL 历史可以追溯到 1972 年 C 语言在 UNIX 计算机上的首次使用.直到 19 ...
- mybatis(三)配置mapper.xml 的基本操作
参考:https://www.cnblogs.com/wuzhenzhao/p/11101555.html XML 映射文件 本文参考mybatis中文官网进行学习总结:http://www.myba ...
- CSS pseudo classes All In One
CSS pseudo classes All In One CSS 伪类 https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes ...
- Apple iPhone 12 Pro 数据迁移方式 All In One
Apple iPhone 12 Pro 数据迁移方式 All In One iPhone 12 Pro https://mp.weixin.qq.com/s/US1Z_69zVQIhV-cNW1E6A ...
- leetcode bug & 9. Palindrome Number
leetcode bug & 9. Palindrome Number bug shit bug "use strict"; /** * * @author xgqfrms ...
- how to fetch html content in js
how to fetch html content in js same origin CORS fetch('https://cdn.xgqfrms.xyz/') .then(function (r ...
- css var all in one & html & root & :root
css var all in one number :root{ --num: 0; } html{ --num: 0; } let html = document.querySelector(`ht ...
- nasm astrstr函数 x86
xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export as ...
- linux cd root directory
linux cd root directory https://www.cyberciti.biz/faq/how-to-change-directory-in-linux-terminal/ htt ...
- js 位掩码
原文 定义掩码 const mask0 = parseInt("00000001", 2); const mask1 = parseInt("00000010" ...