-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Don't bypass cloudflare captcha with xvfb=True #3664
-
Hi everyone!
Scrapper is running on my local machine with ubuntu 22.04. Works well in headed mode and bypass by Cloudflare captcha with cdp + PyAutoGUI but don't with xvfb
Screenshot from 2025年04月09日 23-16-24
Screenshot from 2025年04月09日 23-20-13
Here is the code that works:
with SB(
uc=True, incognito=True, locale="en",
window_position="0,0",
window_size="1920,1080",
headed=True,
) as sb:
sb.activate_cdp_mode(URL)
...
sb.cdp.gui_click_element('#turnstile-captcha div')
...
However, i need to run this on a linux server without gui so i go with (tried 3 options on my local machine with ubuntu 22.04 for test):
with SB(
uc=True, incognito=True, locale="en",
xvfb=True,
xvfb_metrics="1920,1080",
) as sb:
sb.activate_cdp_mode(URL)
...
sb.cdp.gui_click_element('#turnstile-captcha div')
# sb.uc_gui_click_x_y(871, 718)
# sb.cdp.gui_click_x_y(871, 718)
sb.sleep(2)
sb.cdp.save_screenshot("1.png", "_dbg"))
In that case, nothing happens (captcha doesn't bypass, there are no errors in terminal).
There is another thing i don't understand is xvfb_metrics="1920,1080" but screenshots are 1280x701. Did I not configure xvfb correctly or not enough or what other possible reason for not passing the captcha in xvfb "mode"?
Beta Was this translation helpful? Give feedback.
All reactions
Cloudflare-bypass is working normally for me from GitHub Actions using Ubuntu Linux:
- https://github.com/mdmintz/undetected-testing/actions/runs/14366287333/job/40279891349
- https://github.com/mdmintz/undetected-testing/actions/runs/14366591509/job/40280898382
- https://github.com/mdmintz/undetected-testing/actions/runs/14366615650/job/40280972760
Note that Docker leaves a detectable fingerprint, and that many Linux servers (such as AWS) have a non-residential IP address range, which makes automation detectable.
Replies: 1 comment 3 replies
-
Cloudflare-bypass is working normally for me from GitHub Actions using Ubuntu Linux:
- https://github.com/mdmintz/undetected-testing/actions/runs/14366287333/job/40279891349
- https://github.com/mdmintz/undetected-testing/actions/runs/14366591509/job/40280898382
- https://github.com/mdmintz/undetected-testing/actions/runs/14366615650/job/40280972760
Note that Docker leaves a detectable fingerprint, and that many Linux servers (such as AWS) have a non-residential IP address range, which makes automation detectable.
Beta Was this translation helpful? Give feedback.
All reactions
-
Thank you for response. But what about xvfb
with SB(
uc=True,
incognito=True,
locale="en",
xvfb=True,
xvfb_metrics="1920,1080",
) as sb:
sb.set_window_size(1920, 1080)
sb.activate_cdp_mode(URL)
sb.cdp.gui_click_x_y(1400, 800)
and i get error
Exception: PyAutoGUI cannot click on point (1400, 800) outside screen. (Width: 1366, Height: 768)
Why i set up 1920x1080 but virtual screen is 1366x768?
PyAutoGUI==0.9.54
seleniumbase==4.36.1
Beta Was this translation helpful? Give feedback.
All reactions
-
Might be something related to your environment. I'm not seeing that when running in GitHub Actions. Also, be sure you're using the latest version of SeleniumBase (Currently 4.37.1
)
Beta Was this translation helpful? Give feedback.
All reactions
-
upgrade SeleniumBase to 4.37.2. Tried the same code:
with SB(
uc=True,
incognito=True,
locale="en",
xvfb=True,
xvfb_metrics="1920,1080",
) as sb:
sb.set_window_size(1920, 1080)
sb.activate_cdp_mode(URL)
sb.cdp.gui_click_x_y(1400, 800)
got the same error:
Exception: PyAutoGUI cannot click on point (1400, 800) outside screen. (Width: 1366, Height: 768)
After some debugging I found that in activate_cdp_mode(url) an additional virtual screen is created right here. I'm not sure what the idea is here and if it's a bug, but after I commented out this line, my code worked
also without passed xvfb_metrics here:
SeleniumBase/seleniumbase/core/browser_launcher.py
Lines 558 to 566 in b9a89f7
Beta Was this translation helpful? Give feedback.