forked from nickconnors/RTX-3070-Best-Buy-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
87 lines (66 loc) · 2.87 KB
/
bot.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import info
# make sure this path is correct
PATH = "C:\Program Files (x86)\ChromeDriver\chromedriver.exe"
driver = webdriver.Chrome(PATH)
RTX3070LINK1 = "https://www.bestbuy.com/site/nvidia-geforce-rtx-3070-8gb-gddr6-pci-express-4-0-graphics-card-dark-platinum-and-black/6429442.p?skuId=6429442"
RTX3070LINK2 = "https://www.bestbuy.com/site/gigabyte-geforce-rtx-3070-8g-gddr6-pci-express-4-0-graphics-card-black/6437912.p?skuId=6437912"
XBOXONETEST = "https://www.bestbuy.com/site/microsoft-xbox-one-s-1tb-console-bundle-white/6415222.p?skuId=6415222"
driver.get(RTX3070LINK1)
isComplete = False
while not isComplete:
# find add to cart button
try:
atcBtn = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, ".addToCartButton"))
)
except:
driver.refresh()
continue
print("Add to cart button found")
try:
# add to cart
atcBtn.click()
# go to cart and begin checkout as guest
driver.get("https://www.bestbuy.com/cart")
checkoutBtn = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, "/html/body/div[1]/main/div/div[2]/div[1]/div/div/span/div/div[2]/div[1]/section[2]/div/div/div[3]/div/div[1]/button"))
)
checkoutBtn.click()
print("Successfully added to cart - beginning check out")
# fill in email and password
emailField = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "fld-e"))
)
emailField.send_keys(info.email)
pwField = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "fld-p1"))
)
pwField.send_keys(info.password)
# click sign in button
signInBtn = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, "/html/body/div[1]/div/section/main/div[1]/div/div/div/div/form/div[3]/button"))
)
signInBtn.click()
print("Signing in")
# fill in card cvv
cvvField = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "credit-card-cvv"))
)
cvvField.send_keys(info.cvv)
print("Attempting to place order")
# place order
placeOrderBtn = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CSS_SELECTOR, ".button__fast-track"))
)
placeOrderBtn.click()
isComplete = True
except:
# make sure this link is the same as the link passed to driver.get() before looping
driver.get(RTX3070LINK1)
print("Error - restarting bot")
continue
print("Order successfully placed")