(Jul-24-2022, 07:24 PM)Calli Wrote: can we add an exception or??
Yes can do that(
pass
it out so loop will not stop) and can also set shorter time so it goes faster on
timeout
errors.
import requests
with open('ip_lst1.txt') as f:
for ip in f:
try:
ip = ip.strip()
print(ip)
response = requests.get(f"http://{ip}:9200/_cat/indices", timeout=2)
print(response.text.strip())
except Exception as error:
#print(error)
pass
Output:
118.31.106.59
green open .geoip_databases vtWge-U1SLefV6CuavYxCQ 1 0 40 40 37.7mb 37.7mb
118.31.106.59
green open .geoip_databases vtWge-U1SLefV6CuavYxCQ 1 0 40 40 37.7mb 37.7mb
124.221.82.115 # error still continue
118.31.106.59
green open .geoip_databases vtWge-U1SLefV6CuavYxCQ 1 0 40 40 37.7mb 37.7mb
118.31.106.70 # error