Skip to content

Fix captcha detection: login page is now a React SPA, HTML scraping never finds the field - #58

Open
vff wants to merge 1 commit into
jgriss:mainfrom
vff:fix/captcha-detection-spa-login
Open

Fix captcha detection: login page is now a React SPA, HTML scraping never finds the field#58
vff wants to merge 1 commit into
jgriss:mainfrom
vff:fix/captcha-detection-spa-login

Conversation

@vff

@vff vff commented Jul 10, 2026

Copy link
Copy Markdown

Problem

_check_captcha() scrapes the static login page HTML looking for an
element with id="verificationCodeInput" to decide whether a captcha
is required. The login page is now rendered client-side as a React SPA
(script bundles only, empty <body>), so that element is never present
in the HTML response - the check always returns False, and login
fails with AuthenticationException("Login failed: Captcha required but captcha not found.") even when the account genuinely needs a
captcha. Matches #53.

Root cause

_check_captcha() is only ever called from the with_solver decorator
after _login() already raised CaptchaRequiredException, which only
happens when the login response JSON contains "verifyCodeCreate": true. In other words, by the time we reach _check_captcha(), we
already know a captcha is required from the API's own JSON response -
the HTML scraping step is redundant AND broken against the current
frontend.

Fix

Remove the HTML scraping check; go straight to fetching + solving the
captcha image, exactly as the old "captcha found" branch already did.

Testing

Verified end-to-end against a live account on the European (EU5)
server
, uni003eu5 subdomain: login flow (pubkey → validateUser →
captcha required → solve via bundled ONNX model → prevalidate →
re-login with verifycode) completes successfully, and subsequent
authenticated API calls (get_power_status, get_plant_ids) work
correctly. Confirmed the bug was present before this fix (same
account, same credentials).

I have not been able to test against other regions (e.g. China/APAC
servers) - if those use a different login frontend that still serves
the old server-rendered HTML with verificationCodeInput, this change
should be harmless there too, since the only thing removed is a check
that would have returned True anyway on that markup. But flagging
this in case a region-specific regression shows up.

Fixes #53

…ever finds the field

_check_captcha() used bs4 to scrape the login page HTML for an element
with id=verificationCodeInput to decide whether a captcha was required.
The login page is now rendered client-side (React SPA) and that element
is never present in the static HTML response - so the check always
returned False, raising 'Captcha required but captcha not found' even
when the account genuinely needed one (fixes jgriss#53).

_check_captcha() is only called by the with_solver decorator after a
CaptchaRequiredException was already raised from _login(), i.e. after
the login response JSON already confirmed verifyCodeCreate: true. So
the HTML scraping step is unnecessary - go straight to fetching and
solving the captcha image instead.

Tested end-to-end against a live account on the uni003eu5 subdomain:
login, captcha solve via the bundled ONNX model, and session-authenticated
API calls (get_power_status, get_plant_ids) all succeed after this fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exception: Captcha required but captcha not found.

2 participants