Skip to content

Instantly share code, notes, and snippets.

@fgregg
Last active January 26, 2021 14:18
Show Gist options
  • Save fgregg/fd8275060cd18672356ae6e055b3d1aa to your computer and use it in GitHub Desktop.
Save fgregg/fd8275060cd18672356ae6e055b3d1aa to your computer and use it in GitHub Desktop.
cyborg pattern
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
with webdriver.Chrome() as driver:
# load the page
driver.get("https://dapps.36thdistrictcourt.org/ROAWEBINQ/Default.aspx")
case_number_form = driver.find_element_by_xpath('//*[@id="txtDKTCASEID"]')
case_number_form.clear()
case_number_form.send_keys('20346635')
driver.find_element_by_xpath('//*[@id="btnGO"]').click()
# when we can click through the capcha page, we'll get to the result
# page, which will have this new_search option
new_search = WebDriverWait(driver, 1000).until(EC.presence_of_element_located((By.XPATH, '//*[@id="dlROA"]')))
# wait for the user to solve the captcha and click through to the result page
WebDriverWait(driver, timeout=1000, poll_frequency=1) \
.until(EC.staleness_of(new_search))
# do all the data extraction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment