1

I am writing a script that will retrieve a new email and place it on my clipboard everytime I run it.

The site I am scraping runs on a javascript application. I notice an iframe at the end of the website but the js app is outside of it. But I am unable to retrieve the attribute.

AttributeError: 'list' object has no attribute 'get_attribute'
[Finished in 5.8s with exit code 1]

In Python 3.6

from bs4 import BeautifulSoup
import requests
import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options

driver = webdriver.Chrome('/Users/user/Documents/docs/chromedriver')

url = driver.get('https://getnada.com')
element = driver.find_elements(By.CSS_SELECTOR, 'span.address.what_to_copy')

print(element)

1 Answer 1

2

You are setting element to a list of elements:

 //driver.find_elements returns a list
element = driver.find_elements(By.CSS_SELECTOR, 'span.address.what_to_copy')

Either you need to index your list to get the proper element:

element[0].getAttribute()

OR you need to use .find_element to select only one

Sign up to request clarification or add additional context in comments.

2 Comments

Silly mistake on my part, thank you for your help Ryan
@mexitaw Anytime. I was glad to help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.