import requests
import os
import re
picture = input("你想下载什么图片")
os.mkdir(picture)
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=" + picture
yuan_dai = requests.get(url)
tupian_wangzhi = re.findall(r'"objURL":"(.*?)", ', yuan_dai.text)
print(tupian_wangzhi)
a = 0
for i in range(len(tupian_wangzhi)):
print("正在下载第%s张图片" % i)
try:
yuan_dai_ma = requests.get(tupian_wangzhi[a], timeout=2)
a = a + 1
f = open("%s/%s_%d.jpg" % (picture, picture, a), "wb")
f.write(yuan_dai_ma.content)
f.close()
except:
print("这张照片我不要了")
import requests
url = "http://pic2.zhimg.com/50/v2-c139344e88a6e7ea71508c641ab3d465_hd.jpg"
yuan_dai_ma = requests.get("http://pic4.zhimg.com/v2-dacf9f30216e012008cff8a11a6c1f93_b.gif")
f = open("cxk.jpg","wb")
f.write(yuan_dai_ma.content)
f.close()
import requests
import re
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="+"表情包"
yuan_dai = requests.get(url)
tupian_wangzhi = re.findall(r'"objURL":"(.*?)", ',yuan_dai.text)
print(tupian_wangzhi)