Open slashdotblake opened 3 years ago
Program always reads item as being in stock. Then it continuously tries to add to cart.
The problematic code, "item = self.driver.find_element_by_class_name('btn-lg')" says look for btn-lg but regardless of if the item is in stock or not btn-lg is listed.
What if you searched by class name add-to-cart-button instead? Do you think this would work or does best buy use a unique style class for high demand items?
def in_stock(self): time.sleep(5) try: item = self.driver.find_element_by_class_name('btn-lg') #webdriver.ActionChains(self.driver).click_and_hold(self.driver.find_elements_by_class_name('btn btn-primary btn-lg btn-block btn-leading-ficon add-to-cart-button')).perform() #webdriver.ActionChains(self.driver).release().preform() print("In stock!") return True except: print("Item is out of stock") return False
Did you figure this out? Very interested.
I’ve tried this but depending on the page it could have multiple add to cart buttons, so the btn-large was the best approach I could find. I’m in session at my university so I have had little time to work on the bot. I will try to get some updates out soon.
I’ve tried this but depending on the page it could have multiple add to cart buttons, so the btn-large was the best approach I could find. I’m in session at my university so I have had little time to work on the bot. I will try to get some updates out soon.
Hmm maybe you can add a setting that we chance based on location? With instructions of course haha.
I’ve also considered that but from what I saw it’s pixel by pixel and because everyone has a different screen resolution it would cause some to work and others not to. I just need to find an identifier that’s universal
I’ve also considered that but from what I saw it’s pixel by pixel and because everyone has a different screen resolution it would cause some to work and others not to. I just need to find an identifier that’s universal
Another fix can be even if in stock every X tries (can be configurable) it refreshes regardless. This fixes the need to check if in stock or not in stock. Hope this helps in some way.
And the program can know to continue if the product was SUCCESFULLY added to the cart.
Program always reads item as being in stock. Then it continuously tries to add to cart.
The problematic code, "item = self.driver.find_element_by_class_name('btn-lg')" says look for btn-lg but regardless of if the item is in stock or not btn-lg is listed.
What if you searched by class name add-to-cart-button instead? Do you think this would work or does best buy use a unique style class for high demand items?