Skip to main content

Vaccine Watcher

Monitor Vaccine Availability from your Local CVS and Walgreens (US Only).

Open In Colab

Disclaimer: This library is provided as is. It involves some minor browser tricks in order to properly get the availability data. Use at your own risk.

Originally inspired from Vaccine-hunter.js, I wanted to write a pythonic version of it. Somewhat ironically, right after publishing and running it, availability popped up.

What does it do

  1. You can run it as a command line program.
  2. You can run it pythonically through the VaccineWatcher object class - either with real-time polling, or on-demand.

It currently polls CVS and Walgreen's Website through a modified Selenium called Selenium-wire to be able to access the headers and parse the response data. Both CVS and Walgreens use different detectors/cookies in order to determine your location, so using plain requests/sessions was a bit problematic.

This method was the one that ensured consistency no matter which location.

Hopefully, you'll see something like this:

[VaccineWatcher] info : CVS has Available Appointments in HOUSTON, TX

Prerequisites

You should have chromedriver installed and in your paths, which a typical install will do.

# linux
apt-get install chromedriver

# macos - this may cause issues if your Chrome Browser =/= to your Chromedriver version.
brew install chromedriver

# windows - sorry, I don't know.

Installation

vaccinewatcher is on currently only available on Github since it's not stable yet:

pip install --upgrade git+https://github.com/trisongz/vaccinewatcher

Quick Start

The below is the minimum required variables to run the CLI version, with optional flags for additional control.

If you have a lower-spec device, I would suggest increasing the frequency, since due to the modified Selenium, it can tend to be more memory intensive.

# --no-cvs / disables CVS polling
# --no-wg / disables Walgreens polling
# --freq / how many secs between polling. default = 600 secs / 10 mins
# --zapier / provide a Zapier Webhook URL to send notifications to
# --verbose / enable logging for all results, regardless of options.

# make sure if you have multiple words in any variable to have them in quotations.
vaccinewatcher --city "Houston" --state "Texas" --abbr "TX" --zip "77056"

The Pythonic API can be accessed with more ease. Rather than importing the VaccineWatcher object directly, it's recommended to use get_vaccine_watcher which prevents multiple instances from spawning through threading.Lock.

from vaccinewatcher import get_vaccine_watcher

freq = 600
hook = None
check_wg = True 
check_cvs = True
params = {'city': 'San Francisco', 'state': 'California', 'state_abbr': 'CA', 'zipcode': '94117'}

watcher = get_vaccine_watcher(config=params, freq_secs=freq, hook=hook, check_walgreens=check_wg, check_cvs=check_cvs))

# if you want to poll on demand:
res = watcher(check_cvs=False, check_walgreens=True)
# > {'walgreens': False}

## NOTE - It is not recommended to run both a service daemon and on-demand, since the process in polling the websites is sensitive to the steps in which the data is queried. If the browser is interrupted by another call, it will likely mess up.

# to run as a thread daemon
watcher.run()

# to kill the service
watcher.close()

# Access the last captured data
res = watcher.last_check()

# results of res
# {'cvs': {'available': False, 'data': None, 'timestamp': None},
# 'walgreens': {'available': False, 'data': {'appointmentsAvailable': False, 'availabilityGroups': [], 'days': 4, 'radius': 25,
# 'stateCode': 'CA', 'stateName': 'California', 'zipCode': '94117'}, 'timestamp': '03-30-2021 07:17:24'}}

More Advanced Stuff

There are a few additional settings available for the adventurous.

The Hook Function

The hook function is expected to receive two parameters, message and data. Below is the included example Zapier Webhook Listener. Message will only be included when availability changes - i.e. is available, rather than all the time. However, you can choose to send the data that is polled through the daemon by including send_data=True and always_send=True in the initial params, which will then always send the data to your webhook, regardless of status change.

class ZapierWebhook:
    def __init__(self, url):
        self.url = url
        self.s = requests.Session()
        logger.log(f'Initialized Zapier Webhook at {self.url}')

    def __call__(self, message=None, data=None):
        if not message or data:
            return
        params = {}
        if message:
            params['message'] = message
        if data:
            params.update(data)
        params['timestamp'] = create_timestamp()
        r = self.s.post(self.url, json=params)
        if r.status_code == 200:
            logger.log(f'Successfully sent to Zapier Webhook: {params}')
        else:
            logger.log(f'Potential Error sending to Zapier Webhook')

Final Notes

vaccine-appt

If you found this library helpful, please do share it with others. This is what is within my capabilities to help provide a resource and tool to allow others to find vaccine availibility, and help bring an end to the pandemic. If you end up using some parts of this library for something bigger, let me know! I'd love to check it out.

Metadata

Release files for vaccinewatcher 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vaccinewatcher 0.0.1
File Size Uploaded Provenance Actions
vaccinewatcher-0.0.1.tar.gz 8.8 kB Without provenance Details for vaccinewatcher-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vaccinewatcher 0.0.1
File Interpreter ABI Platform Actions
vaccinewatcher-0.0.1-py3-none-any.whl Python 3 none any Details for vaccinewatcher-0.0.1-py3-none-any.whl

Total release size: 18.7 kB

Release files / vaccinewatcher-0.0.1.tar.gz

Download URL vaccinewatcher-0.0.1.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c894cfe87e0fa65de949c73703598996a24495cf3422f7ae11515d80ab808911
BLAKE2b-256 checksum
How to use checksums
a58d1a1bb54e73c7888705051f98a82d8fa1c0126a10abe847bd7de2a8a55885
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.10

Release files / vaccinewatcher-0.0.1-py3-none-any.whl

Download URL vaccinewatcher-0.0.1-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe198b22db104beb0eff05d824d27e61bf316f650fca7666f2b8ce5d4195ea2b
BLAKE2b-256 checksum
How to use checksums
b2676c45ef0c755d0a427f9c1695f19c704a8620c70300c17662cd7e96b77d1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.10

Security for vaccinewatcher 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page