-
Notifications
You must be signed in to change notification settings - Fork 0
/
BB_slot.py
62 lines (48 loc) · 1.85 KB
/
BB_slot.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from selenium import webdriver
import chromedriver_autoinstaller
import sys
import time
import os
import telegram
bot = telegram.Bot(token = "INSERT BOT TOKEN HERE")
chat_id = '''INSERT CHAT ID as INTEGER HERE ''';
def get_bb_slot(url):
chromedriver_autoinstaller.install()
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--ignore-ssl-errors')
driver = webdriver.Chrome(chrome_options =options)
driver.get(url)
print("Please login using OTP and then wait for a while.")
time.sleep(60)
while 1:
driver.get(url)
time.sleep(2)
print("Trying to find a slot!")
try:
driver.find_element_by_xpath("//button[@id = 'checkout']").click()
time.sleep(5)
try:
driver.find_element_by_xpath("//button[@id = 'confirm']").click()
except Exception:
pass
time.sleep(5)
src = driver.page_source
#print(src)
if "checkout" in driver.current_url and not "Unfortunately, we do not have" in src:
time.sleep(15)
src = driver.page_source
if not "Unfortunately, we do not " in src:
for i in range(5):
bot.sendMessage(chat_id = chat_id, text = "SLOTTTT!!!!!!")
except Exception as e:
print("If this message pops up multiple times, please find the error and create a PR!")
print (e)
pass
print("No Slots found. Will retry again.")
#bot.sendMessage(chat_id = chat_id, text = "nope")
time.sleep(50)
def main():
get_bb_slot('https://www.bigbasket.com/basket/?ver=1')
if __name__ == '__main__':
main()