stevenmirabito / balance-check

Check gift card balances for a variety of providers
MIT License
34 stars 16 forks source link

Incapsula #3

Open stevenmirabito opened 5 years ago

stevenmirabito commented 5 years ago

OneVanilla balance checks are protected by Incapsula, which will require additional measures to bypass.

More information: https://kb.apify.com/overcoming-anti-scraping-protection/several-tips-how-to-bypass-website-anti-scraping-protections

j4jstyle commented 2 years ago

Those options are doing the job

        user_agent = random.choice(user_agent_list)
        options.add_argument(f'user-agent={user_agent}')
        options.add_experimental_option("excludeSwitches", ["enable-automation"])
        options.add_experimental_option('useAutomationExtension', False)
        options.add_argument('--disable-blink-features=AutomationControlled')
        options.add_argument('--proxy-server=http://{}'.format(PROXY_HOST + ":" + PROXY_PORT))
        options.headless = False
        options.add_argument("--start-maximized")
        options.add_argument("--window-size=1920x1080")
        options.add_argument('--ignore-certificate-errors')
        options.add_argument('--allow-running-insecure-content')
        options.add_argument("--disable-extensions")
        options.add_argument('--disable-gpu')
        options.add_argument('--disable-dev-shm-usage')
        options.add_argument('--no-sandbox')
        browser = webdriver.Chrome(options=options)

You just need to execute the callback scripts with captcha token.

Sample for VanillaGift

        captcharesult = token
        browser.execute_script("arguments[0].style.display='inline'", browser.find_element_by_id("g-recaptcha-response"))
        browser.execute_script('document.getElementById("g-recaptcha-response").innerHTML = "%s"' % captcharesult)
        callbackpath = f'___grecaptcha_cfg.clients[0].Z.Z.callback("{captcharesult}")'
        callbackpath1 = f'___grecaptcha_cfg.clients[0].l.l.callback("{captcharesult}")'

There's two callbackpath in my sample, because it's keep changing on every request; so make the script test them, if it fail on the first one, it will try the second path; else it will pass.

Good luck