herr_mueller12
herr_mueller12

Reputation: 21

How to extract the Email-Address using Selenium and Python

I'm trying to extract the 'email' using selenium. I want to get the value="[email protected]" directly from the box. How can i do this ?

Website link: https://www.squizzy.de/

how to get value="raipiwro@squizzy.net

Upvotes: 0

Views: 1388

Answers (2)

undetected Selenium
undetected Selenium

Reputation: 193108

To extract the email address using Selenium you need to induce WebDriverWait for the visibility_of_element_located() and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "input[name='mail']"))).get_attribute("value"))
    
  • Using XPATH:

    print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//input[@name='mail']"))).get_attribute("value"))
    
  • Note : You have to add the following imports :

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

Upvotes: 0

n.qber
n.qber

Reputation: 384

Helloww, you're trying to get the attribute value of an element, so we should do that:

driver.find_element("tag name", 'input').get_attribute('value')

First we get the element, then, get it's value attribute which is the email

Upvotes: 1

Related Questions