pcomputo / Whole-Foods-Delivery-Slot

Automated script for Whole Foods and Amazon Fresh delivery slot
Apache License 2.0
443 stars 149 forks source link

Get SLOTS OPEN and then exception when item out of stock #54

Closed amohap2 closed 4 years ago

amohap2 commented 4 years ago

The script reaches SLOTS OPEN and then hits an exception when it reaches this page, which is very common. When an item(s) goes out of stock and amazon pulls the item from the cart:

SLOTS OPEN! Found a slot but it got taken, run script again. Traceback (most recent call last): File "whole_foods_delivery_autobuy.py", line 130, in getWFSlot('https://www.amazon.com/gp/buy/shipoptionselect/handlers/display.html?hasWorkingJavascript=1') File "whole_foods_delivery_autobuy.py", line 127, in getWFSlot autoCheckout(driver) File "whole_foods_delivery_autobuy.py", line 33, in autoCheckout slot_continue_button = driver.find_element_by_xpath('/html/body/div[5]/div[1]/div/div[2]/div/div/div/div/div[2]/div[3]/div/span/span/span/input') File "/Users/amol/.pyenv/versions/2.7.16/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 394, in find_element_by_xpath return self.find_element(by=By.XPATH, value=xpath) File "/Users/amol/.pyenv/versions/2.7.16/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 978, in find_element 'value': value})['value'] File "/Users/amol/.pyenv/versions/2.7.16/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/Users/amol/.pyenv/versions/2.7.16/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[5]/div[1]/div/div[2]/div/div/div/div/div[2]/div[3]/div/span/span/span/input"} (Session info: chrome=81.0.4044.113)

https://puu.sh/FAzq4/e184453bce.png

amohap2 commented 4 years ago

yeah i did. page_source.zip

pcomputo commented 4 years ago

pushed the latest changes. Thank you for this.

amohap2 commented 4 years ago

I don't think the issue was resolved.

refreshed refreshed refreshed SLOTS OPEN! Found a slot but it got taken, run script again. Traceback (most recent call last): File "whole_foods_delivery_autobuy.py", line 135, in getWFSlot('https://www.amazon.com/gp/buy/shipoptionselect/handlers/display.html?hasWorkingJavascript=1') File "whole_foods_delivery_autobuy.py", line 132, in getWFSlot autoCheckout(driver) File "whole_foods_delivery_autobuy.py", line 36, in autoCheckout slot_continue_button = driver.find_element_by_xpath('//[@id="shipoption-select"]/div/div/div/div/div[2]/div[3]/div/span/span/span/input') File "/Users/amol/.pyenv/versions/2.7.16/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 394, in find_element_by_xpath return self.find_element(by=By.XPATH, value=xpath) File "/Users/amol/.pyenv/versions/2.7.16/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 978, in find_element 'value': value})['value'] File "/Users/amol/.pyenv/versions/2.7.16/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/Users/amol/.pyenv/versions/2.7.16/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//[@id="shipoption-select"]/div/div/div/div/div[2]/div[3]/div/span/span/span/input"} (Session info: chrome=81.0.4044.113)

https://puu.sh/FABZG/7e766190a1.png

source.zip

pcomputo commented 4 years ago

ah dang! my bad. Added the proper check. thank you.

amohap2 commented 4 years ago

Not fixed yet. I think.

SLOTS OPEN! Found a slot but it got taken, run script again. Traceback (most recent call last): File "whole_foods_delivery_autobuy.py", line 141, in getWFSlot('https://www.amazon.com/gp/buy/shipoptionselect/handlers/display.html?hasWorkingJavascript=1') File "whole_foods_delivery_autobuy.py", line 138, in getWFSlot autoCheckout(driver) File "whole_foods_delivery_autobuy.py", line 42, in autoCheckout slot_continue_button = driver.find_element_by_xpath('/html/body/div[5]/div[1]/div/div[2]/div/div/div/div/div[2]/div[3]/div/span/span/span/input') File "/Users/amol/.pyenv/versions/2.7.16/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 394, in find_element_by_xpath return self.find_element(by=By.XPATH, value=xpath) File "/Users/amol/.pyenv/versions/2.7.16/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 978, in find_element 'value': value})['value'] File "/Users/amol/.pyenv/versions/2.7.16/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/Users/amol/.pyenv/versions/2.7.16/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[5]/div[1]/div/div[2]/div/div/div/div/div[2]/div[3]/div/span/span/span/input"} (Session info: chrome=81.0.4044.122)

https://puu.sh/FAUUh/9e069083ec.png

source.zip

amohap2 commented 4 years ago

you should check for url change because as it refreshes you could get redirected to amazon.com/gp/buy/itemselect/...

pcomputo commented 4 years ago

no not really. I increased the wait times. I dont see this issue on my end.

amohap2 commented 4 years ago

I'll try to replicate and post the video