whole-foods-deliverance icon indicating copy to clipboard operation
whole-foods-deliverance copied to clipboard

Add support for multiple day / multiple delivery option regions

Open teckboy opened this issue 4 years ago • 14 comments

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:

teckboy avatar Apr 13 '20 22:04 teckboy

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)

mark-thompson avatar Apr 13 '20 22:04 mark-thompson

https://gyazo.com/b58f51cb5fa85b4f92ad4e069975cbd2

teckboy avatar Apr 13 '20 23:04 teckboy

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 avatar Apr 13 '20 23:04 mark-thompson

@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

mark-thompson avatar Apr 14 '20 00:04 mark-thompson

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

BenMQ avatar Apr 17 '20 02:04 BenMQ

@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 avatar Apr 17 '20 03:04 mark-thompson

@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

mark-thompson avatar Apr 20 '20 03:04 mark-thompson

@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

teckboy avatar Apr 20 '20 10:04 teckboy

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

BrendanBTO avatar Apr 20 '20 15:04 BrendanBTO

@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?

mark-thompson avatar Apr 20 '20 22:04 mark-thompson

@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

BrendanBTO avatar Apr 21 '20 00:04 BrendanBTO

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

mark-thompson avatar Apr 21 '20 04:04 mark-thompson

@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

mark-thompson avatar Apr 22 '20 05:04 mark-thompson