forked from pcomputo/Whole-Foods-Delivery-Slot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
whole_foods_delivery_slot_firefox.py
48 lines (37 loc) · 1.3 KB
/
whole_foods_delivery_slot_firefox.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import bs4
from selenium import webdriver
import sys
import time
import os
def getWFSlot(productUrl):
driver = webdriver.Firefox()
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)
slot_pattern = 'Next available'
try:
next_slot_text = soup.find('h4', class_ ='ufss-slotgroup-heading-text a-text-normal').text
if slot_pattern in next_slot_text:
print('SLOTS OPEN!')
os.system('say "Slots for delivery opened!"')
no_open_slots = False
time.sleep(1400)
except AttributeError:
continue
try:
no_slot_pattern = 'No delivery windows available. New windows are released throughout the day.'
if no_slot_pattern == soup.find('h4', class_ ='a-alert-heading').text:
print("NO SLOTS!")
except AttributeError:
print('SLOTS OPEN!')
os.system('say "Slots for delivery opened!"')
no_open_slots = False
getWFSlot('https://www.amazon.com/gp/buy/shipoptionselect/handlers/display.html?hasWorkingJavascript=1')