title: 10X Repeat - Scraping Google News Search Results Python Selenium
body: <p>When I run this code to get the titles and links, I get 10X results. Any idea what I am doing wrong? Is there a way to stop the scraping when we reach the last result on the page?</p>
  <p>Thanks!</p>
  <pre><code>while True:
      web = 'https://news.google.com/search?q=weather&amp;hl=en-US&amp;gl=US&amp;ceid=US%3Aen'
      driver.get(web)
      time.sleep(3)
      
      titleContainers = driver.find_elements(by='xpath', value='//*[@class=&quot;DY5T1d RZIKme&quot;]')
      linkContainers = driver.find_elements(by='xpath', value='//*[@class=&quot;DY5T1d RZIKme&quot;]')
      
      if (len(titleContainers) != 0):
          for i in range(len(titleContainers)):
              counter = counter + 1
              print(&quot;Counter: &quot; + str(counter))
              titles.append(titleContainers[i].text)
              links.append(linkContainers[i].get_attribute(&quot;href&quot;))
              
      else:
          break
  </code></pre>