风月v
2016-07-31 15:20
# -*- coding: UTF-8 -*-
import urllib2
import re
import time
req = urllib2.urlopen('http://www.imooc.com/course/list?c=python')
buf =req.read()
listurl = re.findall(r'http://img.+.jpg',buf)
print listurl
i = 0
for url in listurl:
file = open('D:/python/'+str(i)+'.jpg','w')
req = urllib2.urlopen(url)
buf = req.read()
file.write(buf)
i += 1
time.sleep(1)
file = open('D:/python/'+str(i)+'.jpg','wb')
试一试二进制打开方式
python正则表达式
80575 学习 · 174 问题
相似问题