Skip to content

Instantly share code, notes, and snippets.

@sam210723
Created March 29, 2022 01:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sam210723/9116fcb3309bb304e63d3235fd13f272 to your computer and use it in GitHub Desktop.
Save sam210723/9116fcb3309bb304e63d3235fd13f272 to your computer and use it in GitHub Desktop.
Check the status of your ADS-B Exchange feeder
"""
adsbx-feeder-connection.py
Check the status of your ADS-B Exchange feeder
"""
import sys
import urllib.request
json_output = "json" in sys.argv
# Get status from ADS-B Exchange server
request = urllib.request.urlopen(
urllib.request.Request(
'http://www.adsbexchange.com/myip',
data=None,
headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36'
}
)
)
contents = request.read().decode('utf-8')
request.close()
# Get public IP address
contents = contents[contents.find('Your Web Browser IP<br />') + 34 :]
ip = contents[: contents.find('</strong>')]
# Get ADS-B status
contents = contents[contents.find('<div class="center"><img width="50px" src="./images/') + 52 :]
adsb = True if contents[: contents.find('.png')] == "green" else False
# Get MLAT status
contents = contents[contents.find('<div class="center"><img width="50px" src="./images/') + 52 :]
mlat = True if contents[: contents.find('.png')] == "green" else False
# Write status to console in requested format
if json_output:
import json
print(json.dumps({'ip': ip, 'adsb': adsb, 'mlat': mlat}))
else:
print(f'IP: {ip} ADS-B: {"OK" if adsb else "ERROR"} MLAT: {"OK" if mlat else "ERROR"}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment