Seleniumで将棋DB2の棋士ページURLを取得する

これのつづき

  • あ行〜AI
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()

prayer_urls = []

url = "https://shogidb2.com/players"
driver.get(url)

prayer_prefix_pages = driver.find_elements(By.CLASS_NAME, 'list-group-item-action')
for prayer_prefix_page in prayer_prefix_pages:
    prayer_prefix_page.click()
    prayer_elements = driver.find_elements(By.CLASS_NAME, 'list-group-item')
    prayer_urls += list(map(lambda x: x.get_attribute('href'), prayer_elements))
    driver.back()

driver.close()

print(prayer_urls)