python爬取多页gif图像

                 python爬取多页gif图像


作者:vpoet

日期:大约在夏季




#coding:utf-8
import urllib
import urllib2
import re


# 将正则表达式编译成Pattern对象
rex=r'src="(http://.*?\.gif)"';
pages = ('1','2');
x=1;
for page in pages:
    pageurl = "http://***********.com/default_%s.html" % page;
    Response=urllib2.urlopen(pageurl);
    Html=Response.read();
    lists = re.findall(rex, Html);
    lensofpage=len(lists);
    print lensofpage;
    
    picname = 'page' + page; 
    print picname;
    
    for picurl in lists:
        urllib.urlretrieve(picurl,'C:\Users\Administrator\Desktop\pic\%s.gif' % x);
        print page+picurl;
        x=x+1;

   
   
print 'DownLoadPicOver'
# 图片存储路径:C:\Users\Administrator\Desktop\pic

#测试爬取网址:http://40061111111.com/default_1.html

        
#http://***********.com/zb_users/upload/2015/4/2015040262930869.gif

这个我就不截图了,你懂的

你可能感兴趣的:(python,gif)