拿破仑_QQ
2017-03-19 13:46
# coding=utf-8
import re
import urllib2
req = urllib2.urlopen('https://image.baidu.com/search/index?tn=baiduimage&ipn=r&ct=201326592&cl=2&lm=-1&st=-1&fm=result&fr=&sf=1&fmq=1489897112965_R&pv=&ic=0&nc=1&z=&se=1&showtab=0&fb=0&width=&height=&face=0&istype=2&ie=utf-8&word=跑车')
buf = req.read()
#print buf
web = re.findall(r'''https://.+?\.jpg''',str(buf))
n=1
for i in web:
freq = urllib2.urlopen(i)
fbuf = freq.read()
f = open(str(n)+'.jpg', 'w')
f.write(fbuf)
n += 1
f = open(str(n)+'.jpg', 'w') 把这一句改为f = open(str(n)+'.jpg', 'wb') 采用二进制的方式写入图片
python正则表达式
80575 学习 · 174 问题
相似问题