Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Unable to Click on Cloudflare Challenge Captcha! #3427

Answered by mdmintz
parvinders347 asked this question in Q&A
Discussion options

Hey,

Thanks for the useful seleniumbase.

I want to scrape site but it has cloudflare challenge but location of the captcha isn't default you can see the image below.
Image:

cf detected

Html:

cf html

My code:

from seleniumbase import SB
with SB(uc=True) as sb:
 url = "https://glassdoor.com/job"
 sb.uc_open_with_reconnect(url, 4)
 sb.uc_gui_click_captcha()
 sb.sleep(20)

I tried:

~ I have tried --debug with uc_gui_click_x_y mode to detect the location but its not valid its automatically clicking and gives me wrong coordinates
~ I also tried this but its for turnstile i think, its clicking right but not bypassing:

sb.uc_gui_handle_captcha()
sb.set_messenger_theme(location="top-left")

Note: if you want to test you can use low quality proxy or vpn
Thanks

You must be logged in to vote

When the CF Turnstile isn't in the usual location, use sb.cdp.gui_click_element(selector).
Sometimes that requires other modifications, like below:

from seleniumbase import SB
with SB(uc=True, test=True, ad_block=True) as sb:
 url = "https://www.glassdoor.com/Reviews/index.htm"
 sb.activate_cdp_mode(url)
 sb.sleep(2)
 cf_grid = '[style="display: grid;"]'
 cf_shadow = "%s div div" % cf_grid
 cf_new_style = "display: grid; width: 300px;"
 cf_new_shadow = '[style="%s"] div div' % cf_new_style
 sb.uc_gui_click_captcha()
 if sb.is_element_visible(cf_shadow):
 sb.cdp.set_attributes(cf_grid, "style", cf_new_style)
 sb.cdp.gui_click_element(cf_new_shadow)...

Replies: 1 comment

Comment options

When the CF Turnstile isn't in the usual location, use sb.cdp.gui_click_element(selector).
Sometimes that requires other modifications, like below:

from seleniumbase import SB
with SB(uc=True, test=True, ad_block=True) as sb:
 url = "https://www.glassdoor.com/Reviews/index.htm"
 sb.activate_cdp_mode(url)
 sb.sleep(2)
 cf_grid = '[style="display: grid;"]'
 cf_shadow = "%s div div" % cf_grid
 cf_new_style = "display: grid; width: 300px;"
 cf_new_shadow = '[style="%s"] div div' % cf_new_style
 sb.uc_gui_click_captcha()
 if sb.is_element_visible(cf_shadow):
 sb.cdp.set_attributes(cf_grid, "style", cf_new_style)
 sb.cdp.gui_click_element(cf_new_shadow)
 sb.sleep(2)
 sb.cdp.highlight('[data-test="global-nav-glassdoor-logo"]')
 sb.cdp.highlight('[data-test="site-header-companies"]')
 sb.cdp.highlight('[data-test="search-button"]')
 sb.cdp.highlight('[data-test="sign-in-button"]')
 sb.cdp.highlight('[data-test="company-search-autocomplete"]')

It's possible I may implement something like that directly into sb.uc_gui_click_captcha() in the near future.

You must be logged in to vote
0 replies
Answer selected by mdmintz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /