mark-thompson / whole-foods-deliverance

[Availability notifications, auto-checkout, slot preferences, cart tracking] for Whole Foods / Amazon Fresh
MIT License
54 stars 12 forks source link

Add support for multiple day / multiple delivery option regions #19

Open teckboy opened 4 years ago

teckboy commented 4 years ago

Issuing the following command, it dumps out at the delivery times: python run.py -s 'Amazon Fresh' -c --debug

DEBUG:urllib3.connectionpool:http://127.0.0.1:51412 "POST /session/b2ebca87c5b21e30059084b779d79d97/element HTTP/1.1" 404 1867 DEBUG:selenium.webdriver.remote.remote_connection:Finished Request DEBUG:selenium.webdriver.remote.remote_connection:POST http://127.0.0.1:51412/session/b2ebca87c5b21e30059084b779d79d97/element {"using": "css selector", "value": ".ufss-slotselect-container"} DEBUG:urllib3.connectionpool:http://127.0.0.1:51412 "POST /session/b2ebca87c5b21e30059084b779d79d97/element HTTP/1.1" 404 1867 DEBUG:selenium.webdriver.remote.remote_connection:Finished Request DEBUG:selenium.webdriver.remote.remote_connection:POST http://127.0.0.1:51412/session/b2ebca87c5b21e30059084b779d79d97/element {"using": "css selector", "value": ".ufss-slotselect-container"} DEBUG:urllib3.connectionpool:http://127.0.0.1:51412 "POST /session/b2ebca87c5b21e30059084b779d79d97/element HTTP/1.1" 404 1867 DEBUG:selenium.webdriver.remote.remote_connection:Finished Request ERROR:utils:Timed out waiting for target element: ('class name', 'ufss-slotselect-container') INFO:utils:Dumping page source to: source_dump_1586829983526.html DEBUG:selenium.webdriver.remote.remote_connection:GET http://127.0.0.1:51412/session/b2ebca87c5b21e30059084b779d79d97/source {} DEBUG:urllib3.connectionpool:http://127.0.0.1:51412 "GET /session/b2ebca87c5b21e30059084b779d79d97/source HTTP/1.1" 200 547930 DEBUG:selenium.webdriver.remote.remote_connection:Finished Request Traceback (most recent call last): File "run.py", line 183, in main_loop(driver, args) File "run.py", line 133, in main_loop slots = slots_available(driver, slot_prefs) File "run.py", line 76, in slots_available slots = get_slots(driver) File "run.py", line 30, in get_slots slot_container = get_element(driver, config.Locators.SLOT_CONTAINER) File "/Users/user/whole-foods-deliverance/utils.py", line 56, in get_element EC.presence_of_element_located(locator) File "/Users/user/whole-foods-deliverance/env/lib/python3.7/site-packages/selenium/webdriver/support/wait.py", line 80, in until raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message:

mark-thompson commented 4 years ago

I suspect this was due to an out of stock alert - did you notice one displayed after the error? It should have also dumped the page source. Would you mind providing it here so I can debug? (be sure to redact any personal information on the page)

teckboy commented 4 years ago

https://gyazo.com/b58f51cb5fa85b4f92ad4e069975cbd2

mark-thompson commented 4 years ago

Ah, looks like the slot containers are different in your area - would you mind providing that page source (source_dump_15xxxxxxxxxx.html) via pastebin or similar?

mark-thompson commented 4 years ago

@teckboy Glad to hear you're getting some utility out of this and you're able to help your family! I'll look into the source you provided and make some adjustments. Will reference this issue when I've got a fix

BenMQ commented 4 years ago

@mark-thompson did you already have a sample dump? if not, I can provide one

mark-thompson commented 4 years ago

@BenMQ I did receive a few, yes, but none with open slots. if you happen to find an open slot and can send the source of that page (or at least the XPath/CSS selector logic for the slot/button) for testing, I'd appreciate it.

mark-thompson commented 4 years ago

@teckboy @BenMQ @BrendanBTO Just pushed a quick temp fix that should at least notify you when slots are available. This worked on the source provided by @teckboy , but I'm unable to test on the live site, as I am apparently not yet on the guest list for Amazon Fresh. Auto-checkout and preferences won't work, but if you end up finding a slot, the page source will be dumped and I should be able to add that functionality fairly quickly

teckboy commented 4 years ago

@teckboy @BenMQ @BrendanBTO Just pushed a quick temp fix that should at least notify you when slots are available. This worked on the source provided by @teckboy , but I'm unable to test on the live site, as I am apparently not yet on the guest list for Amazon Fresh. Auto-checkout and preferences won't work, but if you end up finding a slot, the page source will be dumped and I should be able to add that functionality fairly quickly

Got one!!!

[2020-04-20 05:57:38] {_make_request} DEBUG: http://127.0.0.1:64054 "GET /session/2b437aee2ef97aaf72185969824bdbe2/source HTTP/1.1" 200 568564 [2020-04-20 05:57:38] {_request} DEBUG: Finished Request Traceback (most recent call last): File "run.py", line 232, in main_loop(driver, args) File "run.py", line 159, in main_loop slots = get_slots(driver, slot_prefs, slot_route) File "run.py", line 97, in get_slots slot = SlotElementMulti(e) File "/Users/me/Desktop/whole-foods-deliverance-master.20200420/deliverance/elements.py", line 72, in init date_element = self.find_date_element() File "/Users/me/Desktop/whole-foods-deliverance-master.20200420/deliverance/elements.py", line 124, in find_date_element 'Expected 1 date element but found {}'.format(len(elems)) deliverance.exceptions.SlotDateElementAmbiguous: Message: Expected 1 date element but found 0

source_dump-gp-buy-shipoptionselect-handlers-display_20200420T095738Z.rtfd.zip

BrendanBTO commented 4 years ago

For me its erroring out with the same message. Expected 1 date element but found 0.

mark-thompson commented 4 years ago

@teckboy Excellent! Would you mind sending that as html or .txt? RTF changes the formatting such that I can't parse the HTML tags.

@BrendanBTO Could you run with --debug and provide the source?

teckboy commented 4 years ago

source_dump-gp-buy-shipoptionselect-handlers-display_20200420T095427Z.html.zip

BrendanBTO commented 4 years ago

@mark-thompson Here's the source HTML. I edited it to remove all appearances of names, addresses, etc. source_dump-gp-buy-shipoptionselect-handlers-display_20200420T235136Z_Edited.html.zip

mark-thompson commented 4 years ago

@teckboy @BrendanBTO Thanks! Check back in the next day or so for updates

mark-thompson commented 4 years ago

@teckboy @BrendanBTO Give the new version a try. It should be able to detect open slots and may even check out for you, assuming the XPATH logic for the continue button is correct. Run with debug and let me know how it goes