python爬取多頁gif圖像html
做者:vpoetpython
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:\Users\Administrator\Desktop\pic\%s.gif' % x); 24 print page+picurl; 25 x=x+1; 26 27 28 29 print 'DownLoadPicOver' 30 # 圖片存儲路徑:C:\Users\Administrator\Desktop\pic 31 32 #測試爬取網址:http://40061111111.com/default_1.html 33 34 35 #http://***********.com/zb_users/upload/2015/4/2015040262930869.gif
這個我就不截圖了,你懂的 全是美女哦curl