這是我的功能
def offer(rent_start, rent_end, website):
driver.get(website[0])
driver.find_element_by_xpath('//input[@id="btnUpdateQuote"]').click()
這是我的第一個 for 回圈
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)
我想在我的代碼中添加以下第二個 for 回圈,以便首先選擇日期然后打開網站。因此,例如選擇 2021 年 6 月 17 日,然后請求 [電話、筆記本電腦、耳機、鍵盤]。之后選擇 2021 年 6 月 19 日( 2 天)并請求 [電話、筆記本電腦、耳機、鍵盤]
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)
uj5u.com熱心網友回復:
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)
然后,您可以使用alternate_days_list 請求每個URL。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/492624.html
