BestBuy-Automated-Checkout
BestBuy-Automated-Checkout copied to clipboard
Erroneous In-Stock Identification
Looks like it is identifying "out of stock" state as "in stock" and then tries to add to cart.
i don't know if that is normal operation? looks like it's operating the same way for me....maybe the OP can chime in here..
Yeah the same thing is happening to me too. It thinks its in stock and constantly tries to add to cart without refreshing the page.
Can you guys post a picture of the output along with what sku you are using and I will look into it, chances are the webpage has changed and it cant find the element anymore. I'll make any changes needed.
Thats the same output im getting too, im trying to get sku 6429434, thanks.
I have made an update to the instock checking method unfortunately I am not able to test the code right now please advise if the update fixes your issues.
I have made an update to the instock checking method unfortunately I am not able to test the code right now please advise if the update fixes your issues.
It did not change, still trying to add to cart for me....not sure how you can approach this because the website button is showing it's been disabled #
I'd recommend checking the button text and taking appropriate action based on that. EX. Add to cart/Out of Stock/Sold Out.
It's widely used across all product pages for inventory state and is unlikely to change.
itemText = self.driver.find_element_by_class_name('btn-lg').text
if itemText == 'Sold Out':
print('Sold Out')
return False
if itemText == 'Add to Cart':
print("In stock!")
return True
You'll need to consider some logic in the case an item is not in stock or SoldOut, like refreshing the page to check again.
I created a simple logic (for now). I'm not 100% sure if it'll work on Best Buy's que/Please Wait system but it refreshes when an item is out of stock and attempts to add to cart when the yellow button says "Add to Cart". Knowing somewhat of the que system, the que system will start after clicking "Add to Cart" and Best Buy will tell you to "Please Wait". When your que is up, the "Add to Cart" button will appear. In this case, I added some logic so that the bot will stop refreshing when "Add to Cart" appears and run add_toCart
in a while loop until the "Add to Cart" button reappears after the "Please Wait".
def in_stock(self):
time.sleep(5)
try:
item = self.driver.find_element_by_xpath("//button[text()='Add to Cart']")
print("In stock!")
return True
except:
self.driver.refresh()
print("Item is out of stock")
return False
and
instock= bot.in_stock()
incart=False
if (instock==True):
while(incart != True):
incart=bot.add_toCart(incart)
else:
if (instock==False):
while(instock==False):
instock=bot.in_stock()
if (instock==True):
while(incart != True):
incart=bot.add_toCart(incart)
I quickly wrote this without trying to make it efficient so feel to criticize it lol
I'd recommend checking the button text and taking appropriate action based on that. EX. Add to cart/Out of Stock/Sold Out.
It's widely used across all product pages for inventory state and is unlikely to change.
itemText = self.driver.find_element_by_class_name('btn-lg').text if itemText == 'Sold Out': print('Sold Out') return False if itemText == 'Add to Cart': print("In stock!") return True
You'll need to consider some logic in the case an item is not in stock or SoldOut, like refreshing the page to check again.
That's what I thought this program was attempting to do, left-clicking the sold out button continuously waiting for it to change to the add to cart state....would the page not automatically refresh when the add the cart button appeared?
I'd recommend checking the button text and taking appropriate action based on that. EX. Add to cart/Out of Stock/Sold Out. It's widely used across all product pages for inventory state and is unlikely to change.
itemText = self.driver.find_element_by_class_name('btn-lg').text if itemText == 'Sold Out': print('Sold Out') return False if itemText == 'Add to Cart': print("In stock!") return True
You'll need to consider some logic in the case an item is not in stock or SoldOut, like refreshing the page to check again.
That's what I thought this program was attempting to do, left-clicking the sold out button continuously waiting for it to change to the add to cart state....would the page not automatically refresh when the add the cart button appeared?
The original script simply checks if that button (Add to Cart, Sold Out, etc.) is present on the page, doesn't consider its state. When the "Add to Cart" function runs attempts to click that button.
Im not sure if the Best Buy "Add to Cart" button dynamically updates or requires a page refresh. But it's my assumption you to have to refresh the page, update the DOM and the button state if availability changes.
In the case that it does require a refresh the original script would never see the "Add to Cart" button.
I'd recommend checking the button text and taking appropriate action based on that. EX. Add to cart/Out of Stock/Sold Out. It's widely used across all product pages for inventory state and is unlikely to change.
itemText = self.driver.find_element_by_class_name('btn-lg').text if itemText == 'Sold Out': print('Sold Out') return False if itemText == 'Add to Cart': print("In stock!") return True
You'll need to consider some logic in the case an item is not in stock or SoldOut, like refreshing the page to check again.
That's what I thought this program was attempting to do, left-clicking the sold out button continuously waiting for it to change to the add to cart state....would the page not automatically refresh when the add the cart button appeared?
The original script simply checks if that button (Add to Cart, Sold Out, etc.) is present on the page, doesn't consider its state. When the "Add to Cart" function runs attempts to click that button.
Im not sure if the Best Buy "Add to Cart" button dynamically updates or requires a page refresh. But it's my assumption you to have to refresh the page, update the DOM and the button state if availability changes.
In the case that it does require a refresh the original script would never see the "Add to Cart" button.
If that is true then how does the OP claim it worked for him....things that make you go hmmmmm
I managed to get the card before I finished the bot refreshing the page was something I planned to add in but hadn’t had the chance to do so yet
I managed to get the card before I finished the bot refreshing the page was something I planned to add in but hadn’t had the chance to do so yet
Thanks for being honest, I'll keep following in case the page refresh (F5) can be implemented. Just trying to get a 3080 for myself before Cyberpunk drops...if it ever drops lol...
I managed to get the card before I finished the bot refreshing the page was something I planned to add in but hadn’t had the chance to do so yet
Thanks for being honest, I'll keep following in case the page refresh (F5) can be implemented. Just trying to get a 3080 for myself before Cyberpunk drops...if it ever drops lol...
I went in store and had them check I’d try that to
I created a simple logic (for now). I'm not 100% sure if it'll work on Best Buy's que/Please Wait system but it refreshes when an item is out of stock and attempts to add to cart when the yellow button says "Add to Cart". Knowing somewhat of the que system, the que system will start after clicking "Add to Cart" and Best Buy will tell you to "Please Wait". When your que is up, the "Add to Cart" button will appear. In this case, I added some logic so that the bot will stop refreshing when "Add to Cart" appears and run
add_toCart
in a while loop until the "Add to Cart" button reappears after the "Please Wait".def in_stock(self): time.sleep(5) try: item = self.driver.find_element_by_xpath("//button[text()='Add to Cart']") print("In stock!") return True except: self.driver.refresh() print("Item is out of stock") return False
and
instock= bot.in_stock() incart=False if (instock==True): while(incart != True): incart=bot.add_toCart(incart) else: if (instock==False): while(instock==False): instock=bot.in_stock() if (instock==True): while(incart != True): incart=bot.add_toCart(incart)
I quickly wrote this without trying to make it efficient so feel to criticize it lol
Thanks for this, I have tested it and it is working. Reports Item is out of stock and refreshes the page.
So i woke up this morning to this....the bot didn't complete the checkout process...does this mean the other bots beat me to it?
Maybe but it usually means that the website had an error when the bot tried to add it to cart, this is something I’ve seen happen a lot to people on Bestbuy website. The only way is to brute force it and it seems like it sold out
Maybe but it usually means that the website had an error when the bot tried to add it to cart, this is something I’ve seen happen a lot to people on Bestbuy website. The only way is to brute force it and it seems like it sold out
Okay, I have the programs running on two different machines for two different items. Another thing I noticed is I get a random pop-up for a survey when the page is being refreshed. I don't know if that would cause and issue if the bot was trying to add item to cart and the survey popped up...
I never encountered that when I was making the bot so I never gave it a way to close them if it happens again can you send a picture so I know at what point it came up
I'm assuming this error occurred on the site. Maybe the bot needs a logic where if this pops up, it should refresh?
What step was it making you do, when I made the bot Bestbuy didn’t have any form a queuing or bot detection system in place
This happens when the item is in stock and clicks add to cart. A condition might be needed in the add_toCart
function where if "This Item is not in you cart yet" is present then it should refresh and try to add to cart again.
Here is a youtube video of someone attempting to buy a RTX 3070. https://www.youtube.com/watch?v=01gGNj-nK08
so it looks like this is not going to work if they have put anti-bot measures in place....just gonna have to do it the old fashion way and start going into stores....
Here is a youtube video of someone attempting to buy a RTX 3070. https://www.youtube.com/watch?v=01gGNj-nK08
funny how they are talking about switching to AMD....all the Ryzen 4th gen stuff is sold out too lol...I bet the RX cards will be a disaster also...
Maybe but it usually means that the website had an error when the bot tried to add it to cart, this is something I’ve seen happen a lot to people on Bestbuy website. The only way is to brute force it and it seems like it sold out
brute force should never be the answer lol
so it looks like this is not going to work if they have put anti-bot measures in place....just gonna have to do it the old fashion way and start going into stores....
It's possible. The error isn't from an anti-bot. It just requires a simple refresh whenever that error pops up after trying to add to cart. The bot can then do the same process: attempt to add to cart, error?, refresh, attempt to add to cart, etc like a loop
The only anti bot that Best Buy has is cookie based which is only good against terminal based bots. This bot uses Selenium which utilizes the actual browser so it looks like an actual person is using it.
The only anti bot that Best Buy has is cookie based which is only good against terminal based bots. This bot uses Selenium which utilizes the actual browser so it looks like an actual person is using it.
okay how to we get this extra step implemented in the program? somebody has to actually get a card in their cart....