import requests
import re
import os
key = "变形金刚"
os.mkdir(key)
url = "http://image.baidu.com/search/flip?tn=baiduimage&" \
"ipn=r&ct=201326592&cl=2&lm=-1&st=-1&fm=result&fr=&" \
"sf=1&fmq=1497491098685_R&pv=&ic=0&nc=1&z=&se=1&" \
"showtab=0&fb=0&width=&height=&face=0&istype=2&" \
"ie=utf-8&ctd=1497491098685%5E00_1519X735&word="+key
tu_pian_wang_ye = requests.get(url)
dldl = re.findall('"objURL":"(.*?)",',tu_pian_wang_ye.text)
jstm = 0
for i in dldl:
pc = requests.get(i)
jstm = jstm+1
print("--------------正在下载第%d张图片---------------" % jstm)
f = open("%s/text%d.jpg"%(key,jstm), "wb")
f.write(pc.content)
f.close()