前提
python selenium4でページ内にある同じID内の複数aタグのhrefを取得したいです。
以下のコードですと1つしか取得できません。
from selenium.webdriver.firefox.options import Options options = Options() options.add_argument('--headless') path = r'C:\\Users\\geckodriver.exe' driver = webdriver.Firefox(executable_path=path, options=options) driver.get("https://www.irasutoya.com/p/society.html") elements = driver.find_elements(by=By.ID, value='banners') for element in elements: url_link = element.find_element(by=By.TAG_NAME, value="a").get_attribute("href") print(url_link)
複数取得するためelement.find_elementsにすると
AttributeError: 'list' object has no attribute 'get_attribute'
がでます。
複数取得するためにはどのように記載すればいいでしょうか。

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。