Reputation: 119
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)
Upvotes: 1
Views: 148
Reputation: 10765
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
Upvotes: 2