I am using Selenium in Python to download the same file, but with different inputs, each time. So for example, I download data with country selection, "China." In the next iteration, I download the same data, but for country "Brazil."
I am struggling to find easy to understand syntax I can use to rename the downloaded files. The files are currently downloading as "Data.csv" and Data(1).csv." What I want is to have "China-Data.csv" and "Brazil-Data.csv."
The only relevant code I have constructed for this is:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
ChromeOptions=webdriver.ChromeOptions()
driver =webdriver.Chrome('Users/yu/Downloads/chromedriver')
inputcountry.send_keys('China')
inputcountry.send_keys(Keys.RETURN)
I read through this post, but I don't know how to create a forloop that can adapt this to the issue of files having the same name but with numbers at the end. EX: Data(1).csv, Data(2).csv, Data(3).csv
Thanks