python2.7采集图片
#!/bin/pythonimport urllibimport reimport timeimport randomurl = "http://www.jiukuaiyou.com/jiu/all/whole/1"content = urllib.urlopen(url).read()n = re.findall(r"(\d+)",content);maxpage = int(n
·
#!/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'
更多推荐
已为社区贡献2条内容
所有评论(0)