#coding=utf-8 import urllib def getHtml(url): page = urllib.urlopen(url) html = page.read() return html html = getHtml("https://tieba.baidu测试数据/p/5582243679") print html
import re import urllib def getHtml(url): page = urllib.urlopen(url) html = page.read() return html def getImg(html): reg = r'src="(.+?\.jpg)" pic_ext' imgre = re测试数据pile(reg) imglist = re.findall(imgre,html) return imglist html = getHtml("https://tieba.baidu测试数据/p/5582243679") print getImg(html)
#coding=utf-8 import urllib import re def getHtml(url): page = urllib.urlopen(url) html = page.read() return html def getImg(html): reg = r'src="(.+?\.jpg)" pic_ext' imgre = re测试数据pile(reg) imglist = re.findall(imgre,html) x = 0 for imgurl in imglist: urllib.urlretrieve(imgurl,'%s.jpg' % x) x+=1 html = getHtml("https://tieba.baidu测试数据/p/5582243679") print getImg(html)
import urllib.request response = urllib.request.urlopen('http://HdhCmsTestg/500/600') cat_img = response.read() with open('cat_500_600.jpg','wb') as f: f.write(cat_img)
以上就是python下载图片实现方法(超简单)的详细内容,更多请关注Gxl网其它相关文章!
查看更多关于python下载图片实现方法(超简单)的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did84142