Working on a little project to automate reservations since it's impossible to get tables in NYC. I'm slowly picking up my rusty Python knowledge and met a speed bump.
I want the page to load for a date 2 weeks out from today, so I set a variable to get that date in the proper format
I then inserted this date into the URL, however, when I run the code, the URL that comes up has today's date, not the date 2 weeks from now. Even though I confirmed that the variable has the proper date.
Does anybody have thoughts on how to address this?
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
import datetime
ResDate = datetime.date.fromordinal(datetime.date.today().toordinal() 14).strftime("%Y-%m-%d")
print(ResDate)
URL = "https://resy.com/cities/ny/lartusi-ny?date={ResDate}&seats=2"
timeout = 30
driver = webdriver.Chrome()
driver.get(URL)
CodePudding user response:
Try this modified code:
ResDate = datetime.date.fromordinal(datetime.date.today().toordinal() 13).strftime("%Y-%m-%d")
print(ResDate)
url = "https://resy.com/cities/ny/lartusi-ny?date={}&seats=2".format(ResDate)
print(url)