sarperavci / CloudflareBypassForScraping

A cloudflare verification bypass script for webscraping
343 stars 61 forks source link

Cloudflare Bypasser Script - Not Working Anymore #7

Closed Wantphone closed 3 months ago

Wantphone commented 3 months ago

Hello,

I've been using the CloudflareBypasser script to automate the process of bypassing Cloudflare's "just a moment" verification page. However, I've recently encountered an issue where the script no longer works as expected.

Here's a brief description of the problem:

The script does not seem to detect the verification iframe anymore. Even if the iframe is detected, the script fails to click the "Verify you are human" button. The script enters an endless loop without successfully bypassing the verification page. I've ensured that my Chromium driver is up to date and have tried running the script multiple times with no success. It appears that Cloudflare might have changed the structure of their verification pages, which could be causing the script to fail.

Could you please take a look at this issue and provide an update or any guidance on how to resolve it? Your help would be greatly appreciated.

Thank you!

Best regards,

sarperavci commented 3 months ago

Hey, I just ran it and it works perfectly. I updated the script last week. Ensure you are using the latest version of CloudflareBypasser.py .

Wantphone commented 3 months ago

Hello,

Thank you for your prompt response. I ensured that I am using the latest version of CloudflareBypasser.py. However, I am still encountering issues. Here are the details of my setup and the output from my terminal:

from DrissionPage import ChromiumPage, ChromiumOptions
import time

class CloudflareBypasser:
    def __init__(self, driver: ChromiumPage):
        self.driver = driver

    def clickCycle(self):
        if self.driver.wait.ele_displayed('xpath://div/iframe', timeout=1.5):
            time.sleep(1.5)
            self.driver('xpath://div/iframe').ele("Verify you are human", timeout=2.5).click()

    def isBypassed(self):
        title = self.driver.title.lower()
        return "just a moment" not in title

    def bypass(self):
        while not self.isBypassed():
            time.sleep(2)
            print("Verification page detected.  Trying to bypass...")
            time.sleep(2)
            self.clickCycle()

if __name__ == '__main__':
    browser_path = "/usr/bin/google-chrome"
    options = ChromiumOptions()
    options.set_paths(browser_path=browser_path)

    arguments = [
        "-no-first-run",
        "-force-color-profile=srgb",
        "-metrics-recording-only",
        "-password-store=basic",
        "-use-mock-keychain",
        "-export-tagged-pdf",
        "-no-default-browser-check",
        "-disable-background-mode",
        "-enable-features=NetworkService,NetworkServiceInProcess,LoadCryptoTokenExtension,PermuteTLSExtensions",
        "-disable-features=FlashDeprecationWarning,EnablePasswordsAccountStorage",
        "-deny-permission-prompts",
        "-disable-gpu",
    ]

    for argument in arguments:
        options.set_argument(argument)

    driver = ChromiumPage(addr_driver_opts=options)
    driver.get('https://nopecha.com/demo/cloudflare')

    cf_bypasser = CloudflareBypasser(driver)
    cf_bypasser.bypass()

    print("Enjoy the content!")
    print("Title of the page: ", driver.title)

    time.sleep(5)
    driver.quit()

Terminal Output:

C:\Users\swwy1\Anaconda3\python.exe G:/python_learn/日常無碼組荷包/CloudflareBypasser/CloudflareBypasser_test.py
Enjoy the content!
Title of the page:  請稍候...

Process finished with exit code 0 Despite the script running without errors, the page title remains "請稍候..." ("Just a moment..."), indicating that the bypass was not successful. Could you please review the updated script and let me know if there are any additional changes or steps I need to follow?

Thank you for your assistance!

Best regards,

sarperavci commented 3 months ago

This script is designed to bypass Cloudflare pages in English. You can edit the 'Just a moment' message in the title to your language Like this:

    def isBypassed(self):
        title = self.driver.title.lower()
        #return "just a moment" not in title
        return "JUST_A_MOMENT_OR_WHATEVER_IN_YOUR_LANGUAGE" not in title

Or you can just disable it for debugging.

    def isBypassed(self):
        #title = self.driver.title.lower()
        #return "just a moment" not in title
        time.sleep(10)
        return True
Wantphone commented 3 months ago

Hello,

Thank you so much for your quick response and guidance. The issue was indeed related to the language settings. After adjusting the language in the script, it now works perfectly.

I really appreciate your help and the effort you put into maintaining this script. It's been incredibly useful for my projects.

Thanks again!

Best regards,

sarperavci commented 3 months ago

I am happy to see that your issue is resolved. Therefore, I am closing the issue.