This is my function
def offer(rent_start, rent_end, website):
driver.get(website[0])
driver.find_element_by_xpath('//input[@id="btnUpdateQuote"]').click()
This is my 1st for loop
phones = ["https://xxxxxx/", "phones"]
laptops = ["https://xxxxxx/", "laptops"]
headsets = ["https://xxxxxx/", "headsets"]
keyboards = ["https://xxxxxx/", "keyboards"]
websites_list = [phones,laptops,headsets,keyboards]
for website in websites_list:
offer(rent_start, rent_end, website)
I would like to add the following 2nd for loop in my code, so that first the date is selected and then the website opened. So for example 17 June 2021 selected and then [phones,laptops,headsets,keyboards] are requested. After that 19 June 2021 ( 2 days) is selected and [phones,laptops,headsets,keyboards] are requested
rent_start = date(2022, 6, 19)
add_to_rent_start = int(2)
alternate_days = timedelta(days=add_to_rent_start)
rent_end = rent_start alternate days
alternate_days_list = [2, 4, 6, 8]
for alt_days in alternate_days_list:
alternate_days = timedelta(days=add_to_rent_start)
CodePudding user response:
alternate_days_list = [2, 4, 6, 8]
for alt_days in alternate_days_list:
rent_start = date(2022, 6, 19)
alternate_days = timedelta(days=alt_days)
rent_end = rent_start alternate days
for website in websites_list:
offer(rent_start, rent_end, website)
Then, you can request each URL with alternate_days_list.