title: python download & rename
body: <p>I have a problem with my code</p>
  
  <p>The purpose of this code is to download a csv file (which called history.csv) and rename this file to the original name which I use selenium to fetch it out of the web page.
  the first issue here is selenium slowness while loading the web page.
  the second issue is the code stopped after downloading and renaming the first 2 or 3 links of the links list.</p>
  
  <p>here is the event list</p>
  
  <p><a href="https://drive.google.com/file/d/0B5bJvxM9TZkhYXZOSnRDVnhTbFk/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/0B5bJvxM9TZkhYXZOSnRDVnhTbFk/view?usp=sharing</a></p>
  
  <pre><code>from selenium import webdriver
  import os
  events = open('events.txt', 'r')
  for event in events:
      driver = webdriver.Chrome()
      driver.get(event)
      download = driver.find_element_by_xpath('//*[@id="fxec_historytable"]/a').click()
  
      lname = driver.find_element_by_xpath('//*[@id="fxit-h1title"]')
      lname = lname.text
      lname = lname.replace('\n', '')
      name = str(lname)
      print(name)
  
      path = "C:\\Users\\Sayed\\Downloads"
      os.chdir(path)
      print(os.getcwd())
      for file in os.listdir(path):
          fileName, fileExt = os.path.splitext(file)
          nname = '{}{}'.format(name, fileExt)
          os.rename(file, nname)
  </code></pre>
  
  <p>an the error is </p>
  
  <p>C:\Users\Sayed\Anaconda3\python.exe C:/Users/Sayed/PycharmProjects/Tutorial/us.py
  Services Sentiment -European Monetary Union
  C:\Users\Sayed\Downloads
  ZEW Survey - Economic Sentiment -European Monetary Union
  C:\Users\Sayed\Downloads
  Traceback (most recent call last):
    File "C:/Users/Sayed/PycharmProjects/Tutorial/us.py", line 21, in 
      os.rename(file,nname)
  FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'Services Sentiment -European Monetary Union.csv' -> 'ZEW Survey - Economic Sentiment -European Monetary Union.csv'</p>