Bypassing Gains Security in Gainbot: A technical breakdown

Written by Capria Value-Add
March 4, 2025
While building Gainbot to scrape the Gains website (protected by a password and Cloudflare), we tried multiple approaches:
  1. Direct Logins via requests:
    • We sent form data and credentials directly.
    • Gains still blocked these requests with 403 errors and login prompts.
  2. WordPress/Custom Form Attempts:
    • Submitting WordPress login endpoints or hidden form fields.
    • Cloudflare anti‐bot layers continued to reject the requests.
  3. 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.
  4. 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.

Outcome:

With valid cookies, Gains treats Gainbot as an authenticated user, allowing seamless scraping. This method reliably fetches articles without repeated logins or script blockers, keeping Gainbot’s daily refresh tasks and user queries fully operational.

Subscribe to GAIN Newsletter

Be the first to hear the latest investment updates, AI tech trends, and partner insights from Capria Ventures by subscribing to our monthly newsletter. 

We need a few more details...

Join the Community

All founders (and their technical leaders) are invited to join the GAIN GenAI community on WhatsApp. 

Chat with Capria GainBot
Hello! I'm GAINBOT, here to share interesting insights from Capria's webpages. Feel free to search for anything you'd like to learn about.