title: web scraping with python selenium loop and save problem
body: <p>'Hi,I want to save the data I took as csv and txt, but I couldn't.</p>
  <p>Moreover;</p>
  <p>How can I repeat this process multiple times?'</p>
  <pre><code>nextInput = driver.find_element(&quot;xpath&quot;,'//*[@id=&quot;pnnext&quot;]/span[2]').click()
  result = driver.find_elements(By.CSS_SELECTOR, &quot;.GyAeWb cite.iUh30&quot;)
  </code></pre>
  <p>'
  Code;
  '</p>
  <pre><code>from selenium import webdriver
  from selenium.webdriver.common.keys import Keys
  from selenium.webdriver.common.by import By
  import pandas as pd
  import time
  import csv
  import re
  
  
  driver = webdriver.Chrome()
  
  url =&quot;http://google.com&quot;
  driver.get(url)
  
  searchInput = driver.find_element(&quot;xpath&quot;,'/html/body/div[1]/div[3]/form/div[1]/div[1]/div[1]/div/div[2]/input')
  time.sleep(1)
  searchInput.send_keys(&quot;dişçi&quot;)
  time.sleep(2)
  searchInput.send_keys(Keys.ENTER)
  time.sleep(2)
  result = driver.page_source
  result = driver.find_elements(By.CSS_SELECTOR, &quot;.GyAeWb cite.iUh30&quot;)
  
  for index,element in enumerate (result):
    print(index+1,element.text)
  
  result = []
  result = list(set(result))
   
  time.sleep(2)
  
  nextInput = driver.find_element(&quot;xpath&quot;,'//*[@id=&quot;pnnext&quot;]/span[2]').click()
  result = driver.find_elements(By.CSS_SELECTOR, &quot;.GyAeWb cite.iUh30&quot;)
  
  for index,element in enumerate (result):
    print(index+1,element.text)
  
  count = 1
  with open(&quot;siteler.txt&quot;,&quot;w&quot;,encoding=&quot;UTF-8&quot;) as file:
    for item in result:
      file.write(f&quot;{count}-{item}\n&quot;)
      count+=1
  
  driver.close()
  </code></pre>