#!/bin/python
import urllib
import re
import time
import random
url = "http://www.jiukuaiyou.com/jiu/all/whole/1"
content = urllib.urlopen(url).read()
n = re.findall(r"<a href=\"\/jiu\/all\/whole\/\d+\".*?>(\d+)<\/a>",content);
maxpage = int(n[len(n)-1]);
for i in range(1,maxpage):
	url = url = "http://www.jiukuaiyou.com/jiu/all/whole/" + str(i)
	content = urllib.urlopen(url).read()
	m = re.findall(r"data-original=\"(.*?)\"",content)
	if m:
		for k in m:
			index = k.rindex('_',0);
			j = k[0:index]
			con = urllib.urlopen(j).read();
			filename = str(time.time())+".jpg"
			f = file(filename,"wb");
			f.write(con);
			f.close();
	else:
		print 'not search' 

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐