Skip to content

Bug: cloudflare bypass timeout #305

Description

@emadmahdi

Hi,
I noticed a bug in "Botasaurus Driver" that causes the execution to timeout for some cloudflare protected websites. To reproduce the problem please run this small script. I found a simple temporary fix (written below) but it would be good if you can fix it properly. Thank you.

from botasaurus_driver import Driver
driver = Driver()
for i in range(3):
    print()
    #tab = driver.get("https://fajer.show", bypass_cloudflare=False, wait=0)
    tab = driver.get("https://shaid4u.co", bypass_cloudflare=False, wait=0)     # https://shahhied4u.net
    print('before',len(driver.page_html))
    driver.detect_and_bypass_cloudflare()
    print('after ',len(driver.page_html))
    print()

THE FIX:
In your file "botasaurus_driver/driver.py" line 859 .. you have problem with this function "self._tab.select()" .. so I just canceled it using "return None" to make the cloudflare bypass works without timeout.

ORIGINAL:

    def select(self, selector: str, wait: Optional[int] = Wait.SHORT) -> Element:
        elem = self._tab.select(selector, timeout=wait)
        return self._make_element(elem) if elem else None

MODIFIED:

    def select(self, selector: str, wait: Optional[int] = Wait.SHORT) -> Element:
        return None
        elem = self._tab.select(selector, timeout=wait)
        return self._make_element(elem) if elem else None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions