Reputation: 109
I am trying (still) to overcome datadome detection with SeleniumBase in UC mode. I thought i had it, but it seems like datadome is evolving and now throws me to the captcha and after i slide the jigsaw piece by hand i get blocked. I have attached the code in case someone can see what i might have left out. You'll notice some sleeps and pyautogui movements of the cursor to try to look more like a human - prior versions (that were also rejectd) did not have these lines. Thanks in advance for any ideas.(not sure why spacing is a little off, but it's fine in pycharm code)
with SB(uc=True) as sb:
# Maximize window size
sb.maximize_window()
# Open up LOG IN screen
# REMOVED FOR A LITTLE ANONIMITY
# Accept cookies settings
sleep(2)
sb.click('button:nth-child(1)')
# Find Username field and enter it using stored value from credentials array
sleep(2)
sb.type("#p_lt_ContentWidgets_pageplaceholder_p_lt_zoneContent_CHO_Widget_"\
"LoginFormWith"\
"FullscreenBackground_XLarge_loginCtrl_BaseLogin_UserName", credentials[0][0])
# Find/enter user password
sleep(2)
sb.type('#p_lt_ContentWidgets_pageplaceholder_p_lt_zoneContent_CHO_Widget_'
'LoginFormWith'\
'FullscreenBackground_XLarge_loginCtrl_BaseLogin_Password', credentials[0][1])
sleep(2)
sb.click("#p_lt_ContentWidgets_pageplaceholder_p_lt_zoneContent_CHO_Widget_"
"LoginFormWithFullscreen"\
"Background_XLarge_loginCtrl_BaseLogin_LoginButton")
sleep(5)
# print("MSG035 Unable to Select LOG ON Button")
print("Title = ", sb.get_title())
#
pyautogui.moveTo(100, 100)
sb.click("#p_lt_ContentWidgets_pageplaceholder_p_lt_zoneSM30_CHO_Widget_"\
"QuickLinkMenu"\
"_Small_rptItems_ctl03_hrefLink")
# Switch Focus to new window - leave original window to preserve session
sb.switch_to_newest_window()
pyautogui.moveTo(525, 121)
# Move down
sleep(1)
pyautogui.moveTo(534, 155, 1)
pyautogui.click()
pyautogui.moveTo(525, 121)
# Move down to make/change tee times
sleep(1)
pyautogui.moveTo(534, 155, 1)
print("Drop Down")
# Select/hover over the Button after sleeping for 3 seconds
sleep(3)
#sb.slow_click("span:nth-child(1)")
sb.slow_click('//*[@id="rwdNav"]/ul/li[1]/ul/li[1]/a/span')
sleep(1)
pyautogui.moveTo(534, 155, 1)
# Select option
print("Select drop down option")
sleep(3)
sb.slow_click("li:nth-child(1)")
sleep(10)
sb.close()
Upvotes: 0
Views: 433
Reputation: 15556
Sometimes the default reconnect_time
isn't enough in SeleniumBase UC Mode when going to a site that takes a longer time to load. You can customize that. Here's an example script that did that at the beginning:
from seleniumbase import SB
with SB(uc=True, incognito=True, test=True) as sb:
sb.driver.uc_open_with_reconnect("https://pixelscan.net/", 11)
sb.remove_elements("jdiv") # Remove chat widgets
sb.assert_text("No automation framework detected", "pxlscn-bot-detection")
sb.assert_text("You are not masking your fingerprint")
sb.highlight("span.text-success", loops=10)
sb.sleep(1)
sb.highlight("pxlscn-fingerprint-masking div", loops=10, scroll=False)
sb.sleep(1)
sb.highlight("div.bot-detection-context", loops=10, scroll=False)
sb.sleep(3)
If mixing SeleniumBase UC Mode with pyautogui
, first call this before running pyautogui
commands:
driver.disconnect()
And then when done with pyautogui
commands, call this to use Selenium again:
driver.connect()
Note that if you did everything correctly, you might not even need to use pyautogui
at all.
Upvotes: 1