pcomputo / Whole-Foods-Delivery-Slot

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

Compatibility with Today/Tomorrow & 1 hr/2hr #6

Closed IceWilly closed 4 years ago

IceWilly commented 4 years ago

Thank you so much for this. I am using the chrome version. I have done a tweak there to get the sound to output on windows.

os.system('PowerShell -Command "Add-Type –AssemblyName System.Speech; (New-Object System.Speech.Synthesis.SpeechSynthesizer).Speak(\'Delivery available\');"')

But my real issue (I am not a coder at all, i've just stumbled through this enough to get it working), is it doesn't seem its compatible with the current way that it looks for availability. It seems to only be looking in one place, and not the multi-day, 1/2hr windows at the same time.

Is it possible to address this or is the current way the only choice? Even if it could be changed to search for the "Limited Availability text in Today/Tomorrow that would be a useful tool for me personally who will take most any slot giving the current situation. Not like I am out of the house anymore.

Thank you so much and be well.

image

eliperkins commented 4 years ago

Here's my quick hack at it 😬

import bs4

from selenium import webdriver

import sys
import time
import os

def getWFSlot(productUrl):
   headers = {
       'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',
   }

   driver = webdriver.Chrome()
   driver.get(productUrl)           
   html = driver.page_source
   soup = bs4.BeautifulSoup(html)
   time.sleep(60)
   no_open_slots = True

   while no_open_slots:
      driver.refresh()
      print("refreshed")
      html = driver.page_source
      soup = bs4.BeautifulSoup(html)
      time.sleep(4)

      try:
         for day_button in soup.find_all('div', class_ = 'ufss-date-select-toggle-text-container'):
            for string in day_button.stripped_strings:
               print(repr(string))
            for availability in day_button.find_all('div', class_ = 'ufss-date-select-toggle-text-availability'):
               for status in availability.stripped_strings:
                  if status != 'Not available':
                     print('SLOTS OPEN!')
                     os.system('say "Slots for delivery opened!"')
                     no_open_slots = False
                     time.sleep(1400)
         if no_open_slots:
            print('NO SLOTS!')
      except AttributeError as error:
         print('shit broke.')
         print("error: {0}".format(error))
         continue

getWFSlot('https://www.amazon.com/gp/cart/view.html?hasWorkingJavascript=1')

still hangin out with the script running to see if it actually works correctly, but feeling good about it.

edit: just snagged a 2-hr slot for tomorrow with this!

pcomputo commented 4 years ago

I've pushed changes to the Chrome Script. Its an additional check I've added. Hope it helps you! :)

mp42244 commented 4 years ago

Is that a separate script that replaces old script or do you add the code to the existing script?

pcomputo commented 4 years ago

yes same file, you can try pulling the code git pull

mp42244 commented 4 years ago

where so i run git pull? do i need to stop script first?

pcomputo commented 4 years ago

the same place you ran the python script. Stop the running script first. Run git pull then run the python script again.

mp42244 commented 4 years ago

thank you

On Fri, Apr 3, 2020 at 6:47 PM Pooja Ahuja notifications@github.com wrote:

the same place you ran the python script. Stop the running script first. Run git pull then run the python script again.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pcomputo/Whole-Foods-Delivery-Slot/issues/6#issuecomment-608752014, or unsubscribe https://github.com/notifications/unsubscribe-auth/APBIDGEUORQUSYAJOGFZFHTRKZROPANCNFSM4L4C64IA .