Add to cart problem
I have the script running perfectly while testing it, until an item ends up in my cart.
At that stage, the script bot keeps adding more than 1 item to cart (for example gets to 14), and does not go forward to the 'secure checkout' page.
Any idea on how to troubleshoot this?
Thanks for your effort
I saw the same issue. The problem seemed to be related to the URL that the code is expecting. Starting at line 86:
...
await page.goto('https://secure.newegg.com/Shopping/AddtoCart.aspx?Submit=ADD&ItemList=' + config.item_number, { waitUntil: 'load' })
if (page.url().includes("ShoppingCart")) {
...
}
I've changed the if statement to:
...
if (page.url().includes("cart")) {
...
}
Also, the check_cart method errors out because the expected element, span.amount does not exist. I changed it to .summary-content-total and that seems to have fixed the method. It looks like NewEgg has been changing their HTML :)
I was able to implement your 1st of 2 suggestions-- I changed shoppingcart to cart.
Regarding the check_cart issue, I wasn't sure what to do exactly-- do I change span.amount to: span.summary-content-total ? (This is what I tried) Or is there something else I change?
@Codolophier I seem to get "There are no items in the cart" from your code.
@Codolophier I seem to get "There are no items in the cart" from your code.
Does the item in question exist in-stock? If not, set the auto_submit flag to false and try with an item that currently has inventory (as a sanity check).
I tested the checkout logic using something with inventory, like Item N82E16820175006 (SanDisk Extreme 64 GB Micro SD card). I am currently doing a run using Item # N82E16819113663 (AMD 5950x CPU). Since it is not in inventory, the cart is empty. Once inventory is available, it "should" add to the cart and start the checkout process.
I was able to implement your 1st of 2 suggestions-- I changed shoppingcart to cart.
Regarding the check_cart issue, I wasn't sure what to do exactly-- do I change span.amount to: span.summary-content-total ? (This is what I tried) Or is there something else I change?
Try this:
const amountElementName = ".summary-content-total"
try {
await page.waitForSelector(amountElementName, { timeout: 1000 })
var amountElement = await page.$(amountElementName)
....
}
....
Take at look at PR #15 for more information.
@Codolophier I seem to get "There are no items in the cart" from your code.
Does the item in question exist in-stock? If not, set the auto_submit flag to false and try with an item that currently has inventory (as a sanity check).
I tested the checkout logic using something with inventory, like Item N82E16820175006 (SanDisk Extreme 64 GB Micro SD card). I am currently doing a run using Item # N82E16819113663 (AMD 5950x CPU). Since it is not in inventory, the cart is empty. Once inventory is available, it "should" add to the cart and start the checkout process.
I did the test with that SanDisk and it did seem to work. So is "There are no items in the cart" (in cmd) an error or is that standard for an item that is out of stock?
I did the test with that SanDisk and it did seem to work. So is "There are no items in the cart" (in cmd) an error or is that standard for an item that is out of stock?
It means that the item is out of stock. This is where the refresh_time configuration setting comes in to play. If the item was not added to the cart, the bot will keep trying to add it every n seconds, as specified by the refresh_time value. The recommendation is to set this value to something reasonable (e.g., 60, 120, etc.) to avoid refresh insanity :)
I did the test with that SanDisk and it did seem to work. So is "There are no items in the cart" (in cmd) an error or is that standard for an item that is out of stock?
It means that the item is out of stock. This is where the refresh_time configuration setting comes in to play. If the item was not added to the cart, the bot will keep trying to add it every n seconds, as specified by the refresh_time value. The recommendation is to set this value to something reasonable (e.g., 60, 120, etc.) to avoid refresh insanity :)
I've been running it at the default 5 seconds on my other monitor, is that suggestion just to reduce strain or is there a purpose to slowing it down that much?
@Frosty8738 Yes, the purpose is to reduce strain, also to give a bit of time for refresh to occur (i.e., lag, site responsiveness, possible memory leaks from Puppeteer, etc.). But if you aren't seeing any problems with 5 seconds, that should be fine.
PS: My Microcenter bot was running a check every 5 seconds for a while. Eventually timeouts started piling up. I'm not sure if the site noticed my spam and throttled me or if the site was experiencing heavy load due to other bots.
@Frosty8738 Yes, the purpose is to reduce strain, also to give a bit of time for refresh to occur (i.e., lag, site responsiveness, possible memory leaks from Puppeteer, etc.). But if you aren't seeing any problems with 5 seconds, that should be fine.
PS: My Microcenter bot was running a check every 5 seconds for a while. Eventually timeouts started piling up. I'm not sure if the site noticed my spam and throttled me or if the site was experiencing heavy load due to other bots.
I think I was running fine on 5s, not sure exactly how its supposed to look. Running at 10s now and I think it looks the same.
Cool. I had some problems at 5 seconds, Puppeteer would throw "Out of Memory" exceptions after a couple of hours. I'll take another pass at 5 seconds and increase Node's heap. Are you running with any explicit heap overrides, such as max-old-space-size or just running with defaults?
@Codolophier thank you, your fixes worked.
New question: Is there a way to have a vpn or ip address hiding mechanism to load before nightly start up?
Any free recommendations or tips?
Thanks again, your help has been really appreciated.
Is there a way to have a vpn or ip address hiding mechanism to load before nightly start up?
@Mr-Smithers You could create a script that launches the VPN connection, then the bot. Depending on your VPN provider, there should be a program that can be run from a command line, that accepts the desired connection profile.
I haven't taken it to VPN invocation yet, but I have introduced some randomness into the refresh time as follows:
await page.waitForTimeout((config.refresh_time+Math.floor(Math.random() * Math.floor(11))) * 1000)
I used 11 as the ceiling because it is a prime... and I like primes :). I have a few more changes, mostly structural, that I plan to introduce into the next PR.
I tried to add an item that is already in stock to test, for example: 9SIAD1N5PY4247
The bot keeps adding the same item over and over without even trying to checkout. Am using the Canadian branch.
@Kamerabuilt There's a problem with the elements being referenced in the check_cart method. Please check out some of the comments in this thread regarding elements to be changed. Also, take a look the the PR for other possible fixes that you can try in your branch.
same issue, whether im using ataraksias code, ataraksias code with codolophiers updates mentioned above, or codolophiers code from his fork. It get stuck in an infinite loop at line 86/102 depending on whos code, where it says await page.goto('https://secure.newegg.com/Shopping/AddtoCart.aspx?Submit=ADD&ItemList=' + config.item_number, { waitUntil: 'networkidle0' }), itll run that, run hte next line, and go back to 86/102, and just keep looping, adding to my cart and never going to checkout
@Kamerabuilt There's a problem with the elements being referenced in the check_cart method. Please check out some of the comments in this thread regarding elements to be changed. Also, take a look the the PR for other possible fixes that you can try in your branch.
i tried all the comment here... my bot just keep adding to my cart the same prodct . its like a loop . im new with java so its hard for me but i like it. btw thanks for helping us.
im not sure exactly what i did that fixed the issue for me, but i know i ran npm install puppeteer -PUPPETEER_PRODUCT=firefox, and npm install puppeteer -PUPPETEER_PRODUCT=chrome from the c/users/username directory, the neweggbot directory, and the node directory in program files (over kill, yes, but i was getting frustrated and just trying everything) and then suddenly i stopped having the infinite add to cart loop without updating any of the coding on the bot. I would say give that a try, worst outcome is it doesnt fix anything for you.
Now i just have the cannot find checkout button error that i have now confirmed is the kn95 popup, im just not sure how to edit the bot to close that since i have zero experience with javascript
I have tried all the solutions here, but the bot still won't checkout once it adds an item to cart. It just adds the same item to cart again every second or so and never stops. I think it might be a problem with the N95 mask popup, but I tried adding that to my cart beforehand, so it wouldn't pop up, but that didn't work either. The popup didn't appear, but he bot kept looping. What should I do?
I have tried all the solutions here, but the bot still won't checkout once it adds an item to cart. It just adds the same item to cart again every second or so and never stops. I think it might be a problem with the N95 mask popup, but I tried adding that to my cart beforehand, so it wouldn't pop up, but that didn't work either. The popup didn't appear, but he bot kept looping. What should I do?
ecxtly the same problem for me ... i dont know wha to do. anyone here work perfectly with this bot?