#-*-encoding:utf-8-*-python2.7 "' Created on [email protected]: 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-Crawler-Image Capture Save