Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for CAPTCHa #15

Open
jgarciab opened this issue May 13, 2023 · 0 comments
Open

Wait for CAPTCHa #15

jgarciab opened this issue May 13, 2023 · 0 comments

Comments

@jgarciab
Copy link
Contributor

Sometimes Google shows a CAPTCHA. Something like this would check and wait until manually solved.

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

# Define a function to check if CAPTCHA is present on the page
def is_captcha_present(xpath_captcha)
):
    try:
        captcha_element = driver.find_element(By.XPATH, xpath_captcha]')  # Adjust this XPath to match the CAPTCHA container on your target website
        return captcha_element.is_displayed()
    except:
        return False

# Check if CAPTCHA is present
xpath_captcha = '//div[contains(@class, "captcha-container")
if is_captcha_present(xpath_captcha):
    print("CAPTCHA detected. Please solve it to proceed.")

    # Wait for the user to complete the CAPTCHA
    WebDriverWait(driver, 3600).until_not(EC.presence_of_element_located((By.XPATH, xpath_captcha)))  # Adjust this XPath to match the CAPTCHA container on your target website

    print("CAPTCHA solved successfully. Proceeding with scraping.")



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant