{"id":17099083,"url":"https://github.com/dhimmel/hackjohn","last_synced_at":"2025-10-29T16:33:27.518Z","repository":{"id":53490008,"uuid":"161040961","full_name":"dhimmel/hackjohn","owner":"dhimmel","description":"Bot to monitor for southbound permit spaces on the John Muir Trail","archived":false,"fork":false,"pushed_at":"2021-03-28T19:36:07.000Z","size":64,"stargazers_count":26,"open_issues_count":2,"forks_count":18,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-12T23:51:40.202Z","etag":null,"topics":["bot","donahue-pass","hiking","jmt","john-muir-trail","permits","python","yosemite"],"latest_commit_sha":null,"homepage":"https://hive.blog/@dhimmel/introducing-the-hackjohn-bot-for-southbound-john-muir-trail-permits","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dhimmel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-09T13:13:59.000Z","updated_at":"2025-02-07T06:26:57.000Z","dependencies_parsed_at":"2022-08-18T21:22:37.562Z","dependency_job_id":null,"html_url":"https://github.com/dhimmel/hackjohn","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dhimmel/hackjohn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhimmel%2Fhackjohn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhimmel%2Fhackjohn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhimmel%2Fhackjohn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhimmel%2Fhackjohn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dhimmel","download_url":"https://codeload.github.com/dhimmel/hackjohn/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhimmel%2Fhackjohn/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270734952,"owners_count":24636271,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","donahue-pass","hiking","jmt","john-muir-trail","permits","python","yosemite"],"created_at":"2024-10-14T15:08:57.575Z","updated_at":"2025-10-29T16:33:27.463Z","avatar_url":"https://github.com/dhimmel.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bot to monitor for southbound permit spaces on the John Muir Trail\n\n[![Hackjohn CI](https://github.com/dhimmel/hackjohn/workflows/Hackjohn%20CI/badge.svg?branch=main)](https://github.com/dhimmel/hackjohn/actions)\n\nThis repository contains a Python script for monitoring Yosemite's [permit availability report](https://yosemite.org/planning-your-wilderness-permit/).\nVacancies in this table indicate the availability of a southbound John Muir Trail permit, available for immediate reservation by filling out the online [permit request form](https://yosemite.org/yosemite-wilderness-permit-request-form/).\nThis strategy enables securing a soutbound JMT permit after the lottery drawing for a given date.\n\n**Learn more about using hackjohn** and its history of success in the blog post titled [**Introducing the hackjohn bot for southbound John Muir Trail permits**](https://hive.blog/@dhimmel/introducing-the-hackjohn-bot-for-southbound-john-muir-trail-permits) and _The Mercury News_ article titled [**Here’s how to get a coveted reservation to hike the John Muir Trail**](https://www.mercurynews.com/2019/04/22/heres-how-to-get-a-reservation-to-hike-the-john-muir-trail/ \"Written by Lisa M. Krieger on April 22, 2019\").\n\n## Usage\n\nFollow these steps to run hackjohn:\n\n1. Clone this repository.\n2. Modify [`config.py`](config.py) with with the parameters of your permit search.\nThis includes your 2Captcha API key (see the Captcha solving service section) and your tokens for Telegram, IFTTT, and/or Twilio (see the Notifications section).\n3. Then simply run the hackjohn Python script in the `hackjohn` appropriate environment (see Environment section) with:\n\n```shell\npython hackjohn.py\n```\n\nThe script will print some progress messages and at the end it will print a message containing available permit details.\nThe same message will be sent via whichever notification services you set up.\nAn example of the report is:\n\n```\n2021-08-20:\n5 permits for Happy Isles-\u003eLittle Yosemite Valley\n2 permits for Lyell Canyon\n\n2021-09-03:\n1 permit for Happy Isles-\u003eLittle Yosemite Valley\n\nReport last updated 2021-03-20 10:34:32 AM PDT.\n\nPermit request form: https://yosemite.org/yosemite-wilderness-permit-request-form/\nPermit office phone: 209-372-0826\n```\n\nBy default, hackjohn writes the output to the file `hackjohn-output.txt` (as specified by the `OUTPUT_PATH` variable in `config.py`).\nTo avoid repeated notification, hackjohn skips sending notifications if its output matches the pre-existing output.\n\n## Captcha solving service\n\nAs of June 22, 2020, the trailhead report switched to a new website that moved the permit report behind a Recaptcha (the \"I am not a robot\" thing).\nThis made it more difficult for bots to access the report. \n\nhackjohn uses [2Captcha](https://2captcha.com) to solve the Recaptcha and get to the permit report.\nYou will need to create a 2Captcha account and upload some funds, then copy your 2Captcha API key into the `CAPTCHA_API_KEY` variable in [`config.py`](config.py).\n\nThis costs money, but it is very cheap (a few dollars will get you 1000 Recaptchas).\nhackjohn reuses the same Recaptcha authorization as long as it is still valid, so it only calls the 2Captcha service when necessary (currently the authentication lasts about a day, but that is subject to change).\nRealistically, it will cost you at most a couple dollars to run hackjohn multiple times per day for an entire year.\n\n**Note:** There are many alternatives to 2Captcha and they all work pretty much the same way.\nI didn't have any particular reason for choosing 2Captcha.\nFeel free to use a different Captcha solving service, but you will need to make modifications to the code.\n\n## Notifications\n\nhackjohn supports the following services to provide notifications:\n\n* **The Telegram messaging app.**\nRefer to the [webhook2telegram repo](https://github.com/muety/webhook2telegram) for more details.\n  1. Download the Telegram app at https://telegram.org. Mobile and desktop apps are available.\n  2. Message \"\\start\" to @MiddleManBot. It will send back a token.\n  3. In [`config.py`](config.py), set `ENABLE_TELEGRAM` to True and set `TELEGRAM_TOKEN` to the token you received in the previous step.\n\n* **If This Then That (IFTTT).**\n(Thanks Markus Neuhoff for [contributing](https://github.com/dhimmel/hackjohn/pull/4) this feature!)\n  1. Create an applet at https://ifttt.com/create. (You will also need to create an IFTTT account.)\n  2. In the \"If This\" section of your applet, click \"Webhooks\" and then \"Receive a web request\". Give it a name (e.g., \"hackjohn\"). Add this name to the `IFTTT_EVENT_NAME` variable in [`config.py`](config.py).\n  3. In the \"Then That\" section of your applet, select the type of notification you would like to receive. For example, \"Notifications -\u003e Send a rich notification from the IFTTT app\" or \"Email -\u003e Send me an email\".\n  4. Go to https://ifttt.com/maker_webhooks, click on documentation, and copy your key at the top of the screen into the `IFTTT_KEY` variable and set `ENABLE_IFTTT` to True in [`config.py`](config.py).\n\n* **SMS text messages with Twilio.**\n  1. Create an account at https://www.twilio.com.\n  2. In the \"Project Info\" section of your Twilio dashboard, copy your Account SID and Auth Token values into the `TWILIO_ACCOUNT_SID` and `TWILIO_AUTH_TOKEN` variables in [`config.py`](config.py), respectively.\n  3. Click \"Get a trial phone number\" in your Twilio dashboard. Twilio will generate a phone number for your account. Copy this phone number into the `TWILIO_PHONE_NUMBER` variable in [`config.py`](config.py).\n  4. Set the `TWILIO_TO_PHONE` variable to the phone number you want to send notifications to (i.e., your phone number) and set`ENABLE_TWILIO` to True in [`config.py`](config.py).\n  5. **Note:** It costs a small amount of money to operate your Twilio account (currently $1 per month to maintain your phone number plus $0.0075 per message sent).\n  It is often possible to find promos that will add money to your account.\n  For example, there is currently a promo code for $50 in free credits in the \"Basic Training\" section in [Twilio Quest](https://www.twilio.com/quest) (working as of March 2021).\n\nhackjohn can be run without enabling notifications, which is useful for prototyping and development, but less useful for automated monitoring.\n\n## Environment\n\nThe recommended installation method is to create a virtual environment for just hackjohn.\nThis ensures installation does not modify dependencies for other projects.\nTo install a [virtual environment](https://docs.python.org/3/tutorial/venv.html), run the following:\n\n```shell\n# Create a virtual environment in the env directory\npython3 -m venv env\n\n# Activate the virtual environment\nsource env/bin/activate\n\n# Install the required dependencies into the virtual env\npip install --requirement requirements.txt\n\n# Now you can run hackjohn\npython hackjohn.py\n```\n\n## Automation\n\nYou can automate the running of `hackjohn.py` at scheduled times every day.\nAccording to the Yosemite permit office, the trailhead quotas are often updated around 11 AM Pacific Time.\n\nI used `cron`, which despite its awful interface got the job done.\nTherefore, I added the following lines to my `crontab` configuration (replacing `ABOSOLUTE_REPO_PATH` with the absolute path to the directory containing `hackjohn.py`):\n\n```\n# hackjohn bot scheduling (configured for a system on Eastern Time)\n0 13 * * * ABOSOLUTE_REPO_PATH/hackjohn.py \u003e\u003e ABOSOLUTE_REPO_PATH/hackjohn.log\n44 13 * * * ABOSOLUTE_REPO_PATH/hackjohn.py \u003e\u003e ABOSOLUTE_REPO_PATH/hackjohn.log\n59 13 * * * ABOSOLUTE_REPO_PATH/hackjohn.py \u003e\u003e ABOSOLUTE_REPO_PATH/hackjohn.log\n14 14 * * * ABOSOLUTE_REPO_PATH/hackjohn.py \u003e\u003e ABOSOLUTE_REPO_PATH/hackjohn.log\n30 14 * * * ABOSOLUTE_REPO_PATH/hackjohn.py \u003e\u003e ABOSOLUTE_REPO_PATH/hackjohn.log\n40 14 * * * ABOSOLUTE_REPO_PATH/hackjohn.py \u003e\u003e ABOSOLUTE_REPO_PATH/hackjohn.log\n00 15 * * * ABOSOLUTE_REPO_PATH/hackjohn.py \u003e\u003e ABOSOLUTE_REPO_PATH/hackjohn.log\n19 15 * * * ABOSOLUTE_REPO_PATH/hackjohn.py \u003e\u003e ABOSOLUTE_REPO_PATH/hackjohn.log\n00 19 * * * ABOSOLUTE_REPO_PATH/hackjohn.py \u003e\u003e ABOSOLUTE_REPO_PATH/hackjohn.log\n```\n\nRun `crontab -e` to edit your cron configuration.\nIn order to for the cron-scheduled script to run in the proper environment, you must add a shebang pointing to which Python to use.\nFor example, replace the following with the output of `which python` when you have activated the right environment:\n\n```python\n#!/home/username/path/to/hackjohn/env/bin/python\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhimmel%2Fhackjohn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdhimmel%2Fhackjohn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhimmel%2Fhackjohn/lists"}