title: How to to iterate over hrefs with selenium?
body: <p>I've been trying to get all the hrefs of a news article home page. In the end, I want to create something that gives me the n-most used words from all the news articles. To do that, I figured I needed the hrefs first to then click on them one after another. </p>
  
  <p>With a lot of help from another user of this platform, this is the code I've got right now:</p>
  
  <pre><code>from bs4 import BeautifulSoup
  from selenium import webdriver
  
  url = 'https://ad.nl'
  
  # launch firefox with your url above
  # note that you could change this to some other webdriver (e.g. Chrome)
  driver = webdriver.Chrome()
  driver.get(url)
  
  # click the "accept cookies" button
  btn = driver.find_element_by_name('action')
  btn.click()
  
  # grab the html. It'll wait here until the page is finished loading
  html = driver.page_source
  
  # parse the html soup
  soup = BeautifulSoup(html.lower(), "html.parser")
  articles = soup.findAll("article")
  
  for i in articles:
      article = driver.find_element_by_class_name('ankeiler')
      hrefs = article.find_element_by_css_selector('a').get_attribute('href')
      print(hrefs)
  driver.quit()
  </code></pre>
  
  <p>It gives me the first href I think, but it won't iterate over the next ones. It just gives me the first href as many times as it has to iterate. Does anyone know how I make it go to the next href instead of being stuck on the first one?</p>
  
  <p>PS. if anyone has some suggestions on how to further do my little project, feel free to share them as I have a lot of things yet to learn about Python and programming in general. </p>