python爬取多页gif图像
作者:vpoet
mail:vpoet_sir@163.com
1 #coding:utf-8 2 import urllib 3 import urllib2 4 import re 5 6 7 # 将正则表达式编译成Pattern对象 8 rex=r'src="(http://.*?.gif)"'; 9 pages = ('1','2'); 10 x=1; 11 for page in pages: 12 pageurl = "http://***********.com/default_%s.html" % page; 13 Response=urllib2.urlopen(pageurl); 14 Html=Response.read(); 15 lists = re.findall(rex, Html); 16 lensofpage=len(lists); 17 print lensofpage; 18 19 picname = 'page' + page; 20 print picname; 21 22 for picurl in lists: 23 urllib.urlretrieve(picurl,'C:UsersAdministratorDesktoppic\%s.gif' % x); 24 print page+picurl; 25 x=x+1; 26 27 28 29 print 'DownLoadPicOver' 30 # 图片存储路径:C:UsersAdministratorDesktoppic 31 32 #测试爬取网址:http://40061111111.com/default_1.html 33 34 35 #http://***********.com/zb_users/upload/2015/4/2015040262930869.gif
这个我就不截图了,你懂的 全是美女哦