theriley106 / SneakerBotTutorials

Open Source SneakerBot created as a supplement to my "Creating a Sneaker Bot in Python" Youtube Series
https://www.youtube.com/playlist?list=PL3fpqcQTK0f9sACDQstvjxbHzD1L_gr__
MIT License
621 stars 137 forks source link

Error thrown copying cookies. #1

Closed conradj5 closed 7 years ago

conradj5 commented 7 years ago
for cookie in cookies_list: 
     driver.add_cookie(cookie)

This will throw an error as you must be on a page matching the domain of the cookie in order to set it in the webdriver.

Fix by first visiting the splash page before attempting to change cookies.

# you can only set cookies for the driver's current domain so visit the page first then set cookies
driver.get(URL)
# precautionary - delete all cookies first
driver.delete_all_cookies()
for cookie in cookies_list:
     # precautionary - prevent possible Exception - can only add cookie for current domain
     if "adidas" in cookie['domain']:
          driver.add_cookie(cookie)
# once cookies are changed browser must be refreshed
driver.refresh()
theriley106 commented 7 years ago

Thanks Conrad!

I just pushed the changes.

Best, Christopher