简体   繁体   English

Selenium AttributeError: 'list' object 没有属性 'text'

[英]Selenium AttributeError: 'list' object has no attribute 'text'

I am currently scraping a webpage trying to get a list of locations for a job.我目前正在抓取一个网页,试图获取一份工作的位置列表。 The problem is that I need to put it into a list and make it printable but it tells me the title AttributeError.问题是我需要将它放入一个列表并使其可打印,但它告诉我标题 AttributeError。

from selenium import webdriver
from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time
PATH = "D:\CDriver\chromedriver.exe"
driver = webdriver.Chrome(PATH)
LIST = []

driver.get('https://jobs.gecareers.com/global/en/job/R3570239/Service-Project-Leader-Digital-Solutions')
time.sleep(2)

elements = driver.find_elements_by_css_selector('li[au-target-id="127"]')
for ele in elements:
    LIST.append(ele)

print(LIST.text)
driver.quit()

If you want to see the website im scraping it is in the driver.get().如果你想查看我正在抓取的网站,它位于 driver.get() 中。

Selenium .text is meant for web element not for list . Selenium .text用于web element ,不适用于list hence you are getting the above exception.因此你得到了上述异常。

try to do this instead:尝试这样做:

for ele in elements:
    print(ele.text)
    LIST.append(ele)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AttributeError:“列表”对象没有属性“文本” - AttributeError: 'list' object has no attribute 'text' Beautifulsoup AttributeError:“列表”对象没有属性“文本” - Beautifulsoup AttributeError: 'list' object has no attribute 'text' Selenium AttributeError 'list' object 没有属性 send_keys - Selenium AttributeError 'list' object has no attribute send_keys AttributeError: 'list' 对象没有使用 Selenium 和 Python 的属性 'click' - AttributeError: 'list' object has no attribute 'click' using Selenium and Python Selenium AttributeError:list对象没有属性find_element_by_xpath - Selenium AttributeError: list object has no attribute find_element_by_xpath AttributeError: 'list' object 没有属性 'isDisplayed' Python Selenium - AttributeError: 'list' object has no attribute 'isDisplayed' Python Selenium AttributeError: 'list' object 没有属性 'replace' Selenium Python - AttributeError: 'list' object has no attribute 'replace' Selenium Python AttributeError: 'list' 对象没有属性 'click' - Selenium Webdriver - AttributeError: 'list' object has no attribute 'click' - Selenium Webdriver AttributeError: 'list' object 没有属性 'find_element' - Selenium 驱动程序 - AttributeError: 'list' object has no attribute 'find_element' - Selenium driver Selenium:“列表”object 没有属性“文本” - Selenium: 'list' object has no attribute 'text'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM