fix(nnmclub): handle Cloudflare Turnstile CAPTCHA on login
What changed
NNMClub added a Cloudflare Turnstile CAPTCHA to their login form (data-sitekey: 0x4AAAAAAAhS8bNcgfb-0Kni, managed mode). The previous requests-based POST login no longer works because the server now requires a cf-turnstile-response token that can only be generated by a real browser.
Solution
Replaced the simple Session.post() login with a Playwright headless browser flow:
- Opens the login page in headless Chromium
- Fills username and password fields
- Waits up to 30 seconds for Turnstile to auto-complete and inject its token into
cf-turnstile-response - Submits the form and waits for the redirect away from the login URL
- Extracts
phpbb2mysql_4_sidandphpbb2mysql_4_datacookies — same session data as before
Playwright (playwright==1.31.1) is already in requirements.txt. No new dependencies needed.
Notes
- Turnstile in managed mode typically auto-completes without user interaction, even in headless browsers.
- If running in a Docker environment without browser binaries,
playwright install chromiummust be run once.
🤖 Generated with Claude Code
Nice approach. One caveat with headless Chromium on managed Turnstile (0x4AAAAAAAhS8bNcgfb-0Kni): "managed mode typically auto-completes" holds on test environments, but in production Cloudflare can still challenge headless Chromium via fingerprint signals. If you start seeing 30s timeouts or token rejection in CI, the solve step can be decoupled:
import requests
# No Playwright needed for the solve step
res = requests.post(
'https://api.useagentstore.com/solve',
headers={'Authorization': 'Bearer <your_key>'}, # 100 free calls on signup
json={'type': 'turnstile', 'url': 'https://nnmclub.to/forum/login.php', 'sitekey': '0x4AAAAAAAhS8bNcgfb-0Kni'},
).json()
token = res['token'] # submit as cf-turnstile-response
P95 ~2.2s, no Playwright dependency for this step, no Docker browser binary needed. https://useagentstore.com/docs for the signup curl.