QIN2DIM / undetected-playwright

You know who I am
Apache License 2.0
162 stars 29 forks source link

[Q&A] Doesnt work on Ubuntu server #10

Open GrechinStepan opened 1 year ago

GrechinStepan commented 1 year ago

Hi, it works perfect on my Windows PC but doesn`t work on Ubuntu server at all.

QIN2DIM commented 1 year ago

hi, I need you to provide log information, or should you tell me how you use it :>

GrechinStepan commented 1 year ago
@staticmethod
def remove_captcha(page: Page) -> None:
    captcha_checkbox = page.query_selector("input.CheckboxCaptcha-Button")
    if captcha_checkbox:
        captcha_checkbox.click()
        page.wait_for_timeout(5000)
        if 'Press in the following order' in page.content():
            raise Exception('Captcha')
        else:
            page.wait_for_selector('li.serp-item_card', state='visible')

def parser(self, playwright: Playwright) -> None:
        url = f"https://yandex.ru/search/?text={self.request}&lr={self.region_code}"

        browser = playwright.chromium.launch(headless=False)
        context = browser.new_context()
        stealth_sync(context)

        page = context.new_page()

        page.route(re.compile(r"\.(jpg|png|svg)$"), lambda route: route.abort())
        page.goto(url, wait_until='load', timeout=60_000)

        self.remove_captcha(page)

        self.get_all_adv_domains(page)

        context.close()
        browser.close()

On my PC this configuration works without any problems, proxy, user-agent and so on... But on Ubuntu i tried with all of this and still get captcha to solve

GrechinStepan commented 1 year ago

i tried rotating proxy, set viewport_size, set headless=False, different browser args, nothing helped

QIN2DIM commented 1 year ago

I don't understand what you mean "works" -O- It throws an error?

GrechinStepan commented 1 year ago

no errors, just "still get captcha to solve"