检测服务器图片是否存在

import requests 
l=[]
while True:
logging.info('LOOP----')
print('--------------')
sql = 'SELECT id FROM xmt_star_helper_file ORDER BY id DESC'
res = mysql_fetch(sql)
for ac in res:
img_url = 'http://192.168.23.12:8013/file/get?type=toutiao_helper&id=199'.replace('199', str(ac[0]))
try:
# print(img_url)
logging.info(img_url)
if len(requests.get(img_url).content)==0:
l.append(ac[0])
except Exception as e:
print(e)


原文地址:https://www.cnblogs.com/rsapaper/p/8350950.html