码迷,mamicode.com
首页 > 编程语言 > 详细

Python-爬虫-图片抓取保存

时间:2015-11-27 16:57:51      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:

#-*- encoding: utf-8 -*- python2.7 ‘‘‘Created on 2015-11-27@author: max‘‘‘
import re,urllib,time,uuid,os
for i in re.findall(r‘img?src="(.+?\.jpg)"‘,urllib.urlopen("http://www.zhihu.com/collection/38624707").read().replace(" ",""),re.I):
 if not os.path.exists(‘C:\\ATuGuo\\%s‘ %(str(time.localtime(time.time()).__getattribute__("tm_year"))+"-"+str(time.localtime(time.time()).__getattribute__("tm_mon"))+"-"+str(time.localtime(time.time()).__getattribute__("tm_mday")))):
  os.makedirs(‘C:\\ATuGuo\\%s‘  %(str(time.localtime(time.time()).__getattribute__("tm_year"))+"-"+str(time.localtime(time.time()).__getattribute__("tm_mon"))+"-"+str(time.localtime(time.time()).__getattribute__("tm_mday"))))
 urllib.urlretrieve(i,‘C:\\ATuGuo\\%s‘  %(str(time.localtime(time.time()).__getattribute__("tm_year"))+"-"+str(time.localtime(time.time()).__getattribute__("tm_mon"))+"-"+str(time.localtime(time.time()).__getattribute__("tm_mday")))+"\\%s.jpg" %str(uuid.uuid1()))

Python-爬虫-图片抓取保存

标签:

原文地址:http://www.cnblogs.com/guochaolang/p/5000646.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!