While building Gainbot to scrape the Gains website (protected by a password and Cloudflare), we tried multiple approaches:- Direct Logins via requests:
- We sent form data and credentials directly.
- Gains still blocked these requests with 403 errors and login prompts.
- WordPress/Custom Form Attempts:
- Submitting WordPress login endpoints or hidden form fields.
- Cloudflare anti‐bot layers continued to reject the requests.
- Selenium (Headless Browser):
- We attempted to replicate a real browser login flow.
- Cloudflare’s JavaScript checks still flagged the headless session, returning “enable JavaScript and cookies” messages.
- The Working Solution: Session Cookies
- Export Browser Cookies: We logged in manually via a normal browser, then used the browser’s Developer Tools to export the authenticated session cookies into a JSON file.
- Attach Cookies to Requests: Gainbot reads these JSON cookies and adds them to every requests.get(…). The server recognizes this as a valid session, bypassing both password prompts and Cloudflare’s checks.

