Search code examples
pythonpython-3.xbeautifulsouphtml-parsing

Python, trying to parse strange things


I am trying to parse content from specific website for example https://temp-mail.org/en i want parse Email address, am not familiar with java or what is this idk. Please Help how can i do this? what i have done it only parse content but in content i cant find field with email address. Can u explain what is this

<input class="emailbox-input opentip disabledText" data-original-title="Your Temporary Email Address" data-placement="bottom" data-value="Loading" id="mail" onclick="select(this);" readonly="" type="text"/>

i using this code:

>>>page = requests.get('https://temp-mail.org/en/')
>>>soup = BeautifulSoup(page.text, 'html.parser')
>>>soup

Now i tried with silenium if i am right, but no output...

>>>driver = webdriver.Chrome('/usr/bin/chromedriver', options=options)
>>>driver.get('https://temp-mail.org/en/')
>>> elemts = driver.find_element_by_id(id_='mail')
>>> elemts
<selenium.webdriver.remote.webelement.WebElement (session="4bfd1e55807ce38331d70d93b3e9ff94", element="64def6cd-5c1a-4bf0-bf7e-0419718ac256")>
>>>elemts.text
''

Solution

  • If you want to get the value of the email address thats prepopulated by the javascript then just get the value of the input field.

    from selenium import webdriver
    options = webdriver.ChromeOptions()
    driver = webdriver.Chrome()
    driver.get('https://temp-mail.org/en/')
    elemts = driver.find_element_by_id(id_='mail')
    print("Email address:", elemts.get_attribute('value'))
    

    OUTPUT

    Email address: kokida8790@etcone.net