Last active
May 12, 2021 00:47
-
-
Save mike-weiner/b8f5ab903047a05c3d3579450c919be4 to your computer and use it in GitHub Desktop.
A Python version of a script that will use the open source Vaccine Spotter API to print out all vaccine centers in a specific city with which vaccine sites have appointments available.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import requests | |
# get API url provided by https://www.vaccinespotter.org/api/ | |
# this URL can be changed to any of the other states found at the URL above | |
URL = "https://www.vaccinespotter.org/api/v0/states/MN.json" # CHANGE STATE HERE | |
requestResponse = requests.get(URL) | |
parsedJSONResponse = requestResponse.json() | |
for location in parsedJSONResponse['features']: | |
if (location['properties']['city'].lower() == "rochester"): # CHANGE CITY NAME HERE (repleace rochester with the name of your city - city should be located in the state you are requesting) | |
print(location['properties']['name']) | |
print(location['properties']['address']) | |
if (str(location['properties']['appointments_available']).lower() == "true"): | |
print("Appointments Available: " + '\x1b[1;37;42m' + str(location['properties']['appointments_available']) + '\x1b[0m') | |
else: | |
print("Appointments Available: " + '\x1b[1;37;41m' + str(location['properties']['appointments_available']) + '\x1b[0m') | |
print(location['properties']['url']) | |
print("---") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Below is a PHP version of this script that could be used on a web server. This script is identical to the Python version above.
vaccine-spot.php