Skip to content

Instantly share code, notes, and snippets.

@DamageESP
Created February 1, 2025 16:38
Show Gist options
  • Save DamageESP/b3a0bd3707cac8480cec64e46c7640ed to your computer and use it in GitHub Desktop.
Save DamageESP/b3a0bd3707cac8480cec64e46c7640ed to your computer and use it in GitHub Desktop.
datadome detected
from seleniumbase import SB
def click_item_link(sb):
sb.scroll_into_view(".item-link")
sb.save_screenshot_to_logs()
sb.cdp.click(".item-link")
with SB(uc=True, test=True, window_size="1366,768", xvfb=True, proxy="0.tcp.eu.ngrok.io:15420") as sb:
url = "https://www.idealista.com/pro/engel-volkers-barcelona/"
sb.activate_cdp_mode(url)
sb.sleep(2.5)
sb.save_screenshot_to_logs()
sb.cdp.click_if_visible("#didomi-notice-agree-button")
sb.sleep(1)
# take a screenshot before and after clicking the link
sb.save_screenshot_to_logs()
click_item_link(sb)
sb.save_screenshot_to_logs()
sb.sleep(2)
try:
# Save the price of the item
price = sb.cdp.get_text(".info-data-price")
sqmt_price = sb.cdp.get_text(".squaredmeterprice .flex-feature-details:nth-child(2)")
print(f"Price: {price}")
print(f"Price per square meter: {sqmt_price}")
except Exception as e:
print(f"Error: {e}")
# log the current url
print(f'Current URL: {sb.get_current_url()}')
raise e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment