Closed ElPafa closed 3 years ago
Amazon page html has changed. Sometimes the original html is provided, sometimes new html is provided. The bot cannot handle the new html yet, until someone submits an update to fix it.
Amazon page html has changed. Sometimes the original html is provided, sometimes new html is provided. The bot cannot handle the new html yet, until someone submits an update to fix it.
Then there is no Fix for it yet?
Yes, that's what I just said.
I have got the same issue. 2021-08-18 03:41:22|0.6.9|INFO|Item B0149AEHNC in stock and in reserve range: 24.99 + 0.00 shipping <= 25.0 2021-08-18 03:41:22|0.6.9|INFO|Adding to cart 2021-08-18 03:41:22|0.6.9|ERROR|Unable to find offering ID to add to cart. Using legacy mode. 2021-08-18 03:41:26|0.6.9|WARNING|Did not add to cart, trying again 2021-08-18 03:41:29|0.6.9|INFO|Found 7 offers for B0149AEHNC. Evaluating offers... 2021-08-18 03:41:29|0.6.9|INFO|Item B0149AEHNC in stock and in reserve range: 24.99 + 0.00 shipping <= 25.0 2021-08-18 03:41:29|0.6.9|INFO|Adding to cart 2021-08-18 03:41:29|0.6.9|ERROR|Unable to find offering ID to add to cart. Using legacy mode. 2021-08-18 03:41:33|0.6.9|WARNING|Did not add to cart, trying again 2021-08-18 03:41:36|0.6.9|INFO|Found 7 offers for B0149AEHNC. Evaluating offers... 2021-08-18 03:41:36|0.6.9|INFO|Item B0149AEHNC in stock and in reserve range: 24.99 + 0.00 shipping <= 25.0 2021-08-18 03:41:36|0.6.9|INFO|Adding to cart 2021-08-18 03:41:36|0.6.9|ERROR|Unable to find offering ID to add to cart. Using legacy mode. 2021-08-18 03:41:40|0.6.9|WARNING|Did not add to cart, trying again 2021-08-18 03:41:43|0.6.9|INFO|Found 7 offers for B0149AEHNC. Evaluating offers... 2021-08-18 03:41:44|0.6.9|INFO|Item B0149AEHNC in stock and in reserve range: 24.99 + 0.00 shipping <= 25.0 2021-08-18 03:41:44|0.6.9|INFO|Adding to cart 2021-08-18 03:41:44|0.6.9|ERROR|Unable to find offering ID to add to cart. Using legacy mode. 2021-08-18 03:41:47|0.6.9|WARNING|Did not add to cart, trying again 2021-08-18 03:41:47|0.6.9|INFO|max add to cart retries hit, returning to asin check 2021-08-18 03:41:47|0.6.9|INFO|Item B0149AEHNC in stock and in reserve range: 22.44 + 0.00 shipping <= 25.0 2021-08-18 03:41:47|0.6.9|INFO|Adding to cart 2021-08-18 03:41:47|0.6.9|ERROR|Unable to find offering ID to add to cart. Using legacy mode. 2021-08-18 03:41:50|0.6.9|WARNING|Did not add to cart, trying again 2021-08-18 03:41:50|0.6.9|INFO|max add to cart retries hit, returning to asin check 2021-08-18 03:41:50|0.6.9|INFO|Item B0149AEHNC in stock and in reserve range: 22.99 + 0.00 shipping <= 25.0 2021-08-18 03:41:50|0.6.9|INFO|Adding to cart 2021-08-18 03:41:50|0.6.9|ERROR|Unable to find offering ID to add to cart. Using legacy mode. 2021-08-18 03:41:53|0.6.9|WARNING|Did not add to cart, trying again 2021-08-18 03:41:54|0.6.9|INFO|max add to cart retries hit, returning to asin check 2021-08-18 03:41:54|0.6.9|INFO|Item B0149AEHNC in stock and in reserve range: 24.49 + 0.00 shipping <= 25.0 2021-08-18 03:41:54|0.6.9|INFO|Adding to cart 2021-08-18 03:41:54|0.6.9|ERROR|Unable to find offering ID to add to cart. Using legacy mode. 2021-08-18 03:41:57|0.6.9|WARNING|Did not add to cart, trying again 2021-08-18 03:41:57|0.6.9|INFO|max add to cart retries hit, returning to asin check 2021-08-18 03:41:57|0.6.9|INFO|Offers exceed price range (10.00-25.00) 2021-08-18 03:41:57|0.6.9|ERROR|Traceback (most recent call last): File "C:\Users\TheMinerCo.com\Music\fairgame-0.6.9\cli\cli.py", line 66, in decorator func(*args, kwargs) File "C:\Users\TheMinerCo.com\Music\fairgame-0.6.9\cli\cli.py", line 257, in amazon amzn_obj.run(delay=delay, test=test) File "C:\Users\TheMinerCo.com\Music\fairgame-0.6.9\stores\amazon.py", line 269, in run asin = self.run_asins(delay) File "C:\Users\TheMinerCo.com\Music\fairgame-0.6.9\utils\debugger.py", line 34, in wrapper_debug value = func(*args, *kwargs) File "C:\Users\TheMinerCo.com\Music\fairgame-0.6.9\stores\amazon.py", line 459, in run_asins if self.check_stock(asin, self.reserve_min[i], self.reserve_max[i]): File "C:\Users\TheMinerCo.com\Music\fairgame-0.6.9\utils\debugger.py", line 34, in wrapper_debug value = func(args, kwargs) File "C:\Users\TheMinerCo.com\Music\fairgame-0.6.9\stores\amazon.py", line 853, in check_stock in_stock = self.check_stock( File "C:\Users\TheMinerCo.com\Music\fairgame-0.6.9\utils\debugger.py", line 34, in wrapper_debug value = func(*args, *kwargs) File "C:\Users\TheMinerCo.com\Music\fairgame-0.6.9\stores\amazon.py", line 853, in check_stock in_stock = self.check_stock( File "C:\Users\TheMinerCo.com\Music\fairgame-0.6.9\utils\debugger.py", line 34, in wrapper_debug value = func(args, **kwargs) File "C:\Users\TheMinerCo.com\Music\fairgame-0.6.9\stores\amazon.py", line 736, in check_stock condition: List[WebElement] = atc_button.find_elements_by_xpath( File "C:\Users\TheMinerCo.com.virtualenvs\fairgame-0.6.9-cZJPwd6N\lib\site-packages\selenium\webdriver\remote\webelement.py", line 381, in find_elements_by_xpath return self.find_elements(by=By.XPATH, value=xpath) File "C:\Users\TheMinerCo.com.virtualenvs\fairgame-0.6.9-cZJPwd6N\lib\site-packages\selenium\webdriver\remote\webelement.py", line 684, in find_elements return self._execute(Command.FIND_CHILD_ELEMENTS, File "C:\Users\TheMinerCo.com.virtualenvs\fairgame-0.6.9-cZJPwd6N\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute return self._parent.execute(command, params) File "C:\Users\TheMinerCo.com.virtualenvs\fairgame-0.6.9-cZJPwd6N\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Users\TheMinerCo.com.virtualenvs\fairgame-0.6.9-cZJPwd6N\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document (Session info: chrome=92.0.4515.131)
Alright got a tentative fix for this locally. If you replace the following in stores/amazon.py
# Get the offering ID
offering_id_elements = atc_button.find_elements_by_xpath(
"./preceding::input[@name='offeringID.1'][1] | ./preceding::input[@id='offerListingID']"
)
if offering_id_elements:
log.info("Attempting Add To Cart with offer ID...")
offering_id = offering_id_elements[0].get_attribute("value")
With
# Get the offering ID
try:
atc_action : List[WebElement] = atc_button.find_elements_by_xpath("./ancestor::span[@data-action='aod-atc-action']")
full_atc_action_string = atc_action[0].get_attribute('data-aod-atc-action')
offering_id = json.loads(full_atc_action_string)["oid"]
except:
log.error("Unable to find OfferID...")
return False
if offering_id:
log.info("Attempting Add To Cart with offer ID...")
You should have support for getting the offeringID from the updated HTML. Would like some confirmation that ./ancestor:: will always pull the closest matching span item though, otherwise I can't guarantee that this code will pull the OfferingID from the correct item.
Can you please make this a pull request?
Would have originally, but I'm unable to make a PR branch. Likely just need to get added as a contributor.
You don't need to make a branch. Fork the repo and load it on to your fork, then you can PR your fork.
Huh! I didn't know you could do that. Thanks! PR is open at:
Hi The bot start working and keep serching for gpu to buy, once it found one it trys to add to cart and then shut down.
I upload here the picture of the error.![WhatsApp Image 2021-08-16 at 2 19 57 PM](https://user-images.githubusercontent.com/89034316/129618333-a7c836c4-b3d5-4175-b64d-d0a920f91c56.jpeg)
Please if anyone know how to fix this let me know.
Thank you!!
Anyway I drop the error code here.
2021-08-16 14:22:59|0.6.9|ERROR|Unable to find offering ID to add to cart. Using legacy mode. 2021-08-16 14:23:02|0.6.9|WARNING|Did not add to cart, trying again 2021-08-16 14:23:02|0.6.9|INFO|max add to cart retries hit, returning to asin check 2021-08-16 14:23:02|0.6.9|INFO|Offers exceed price range (519.00-650.00) 2021-08-16 14:23:02|0.6.9|ERROR|Traceback (most recent call last): File "C:\Users\polac\OneDrive\Documents\GitHub\fairgame\cli\cli.py", line 66, in decorator func(*args, kwargs) File "C:\Users\polac\OneDrive\Documents\GitHub\fairgame\cli\cli.py", line 257, in amazon amzn_obj.run(delay=delay, test=test) File "C:\Users\polac\OneDrive\Documents\GitHub\fairgame\stores\amazon.py", line 269, in run asin = self.run_asins(delay) File "C:\Users\polac\OneDrive\Documents\GitHub\fairgame\utils\debugger.py", line 34, in wrapper_debug value = func(*args, *kwargs) File "C:\Users\polac\OneDrive\Documents\GitHub\fairgame\stores\amazon.py", line 459, in run_asins if self.check_stock(asin, self.reserve_min[i], self.reserve_max[i]): File "C:\Users\polac\OneDrive\Documents\GitHub\fairgame\utils\debugger.py", line 34, in wrapper_debug value = func(args, kwargs) File "C:\Users\polac\OneDrive\Documents\GitHub\fairgame\stores\amazon.py", line 853, in check_stock in_stock = self.check_stock( File "C:\Users\polac\OneDrive\Documents\GitHub\fairgame\utils\debugger.py", line 34, in wrapper_debug value = func(*args, *kwargs) File "C:\Users\polac\OneDrive\Documents\GitHub\fairgame\stores\amazon.py", line 853, in check_stock in_stock = self.check_stock( File "C:\Users\polac\OneDrive\Documents\GitHub\fairgame\utils\debugger.py", line 34, in wrapper_debug value = func(args, **kwargs) File "C:\Users\polac\OneDrive\Documents\GitHub\fairgame\stores\amazon.py", line 736, in check_stock condition: List[WebElement] = atc_button.find_elements_by_xpath( File "C:\Users\polac\OneDrive\Documents\GitHub\fairgame.venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 381, in find_elements_by_xpath return self.find_elements(by=By.XPATH, value=xpath) File "C:\Users\polac\OneDrive\Documents\GitHub\fairgame.venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 684, in find_elements return self._execute(Command.FIND_CHILD_ELEMENTS, File "C:\Users\polac\OneDrive\Documents\GitHub\fairgame.venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute return self._parent.execute(command, params) File "C:\Users\polac\OneDrive\Documents\GitHub\fairgame.venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Users\polac\OneDrive\Documents\GitHub\fairgame.venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document (Session info: chrome=92.0.4515.131)