偶尔发现的爱壁纸壁纸批量下载url,但是下下来的壁纸重复的挺多的,仅供娱乐,不喜勿喷。
import requests,time
photo_id = 10002048
count = 1
def get_image(img_url):
try:
global count
print '正在获取第%d张壁纸'%(count)
res = requests.get(img_url)
print(res)
if res.status_code != 200:
return False
img_name = img_url.split('/')[-1]
print '正在保存到-->E:/wall_photo/%s' % (img_name)
with open('E:/wall_photo/%s'%(img_name),'wb') as fp:
fp.write(res.content)
return True
except Exception as msg:
print msg.message
return False
for i in range(100000):
base_url = 'http://s.qdcdn.com/c/%s,1366,768.jpg'%(str(photo_id))
if get_image(base_url):
time.sleep(1)
count += 1
photo_id += 3