Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

fix all the errors #6

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

fix all the errors #6

wants to merge 10 commits into from

Conversation

stan2474
Copy link

basically all the errors are fixed in the pull request that people had

@eg9y
Copy link
Owner

eg9y commented Nov 17, 2020

Thanks for these changes! I really appreciate it. There's something I want to mention though.The whole concept behind PS5Bot is to keep auto reloading different sites for PS5, but after some thought, this concept is very flawed. Maybe this could be helpful in launch day, but I feel a program that checks for stock availability is more useful since then it'll be much less memory-intensive and easier to add more sites to listen to. Basically like this: https://github.com/jef/streetmerchant. For this reason, I'm tempted to archive this project. But from the looks of it, there has been a decent amount of interest over this. So if you and others are interested in collaborating on a different version that would be awesome. Any thoughts?

@stan2474
Copy link
Author

Thanks for these changes! I really appreciate it. There's something I want to mention though.The whole concept behind PS5Bot is to keep auto reloading different sites for PS5, but after some thought, this concept is very flawed. Maybe this could be helpful in launch day, but I feel a program that checks for stock availability is more useful since then it'll be much less memory-intensive and easier to add more sites to listen to. Basically like this: https://github.com/jef/streetmerchant. For this reason, I'm tempted to archive this project. But from the looks of it, there has been a decent amount of interest over this. So if you and others are interested in collaborating on a different version that would be awesome. Any thoughts?

I'm interested

@AnhNguyen97
Copy link

I'm interested

@eg9y
Copy link
Owner

eg9y commented Nov 18, 2020

Ok yall, here's the plan:

  • address existing Issues
    • can't call ps5bot. I believe it's addressed in this PR
    • add login for other sites besides Target
  • while checking stock availability, keep puppeteer in headless mode. This means running the browser without displaying the UI.
  • If a site is out-of-stock, display 'sitename OUT OF STOCK' in the CLI. Else if in-stock, display 'sitename IN STOCK!', instantiate a browser (not in headless mode) and run the existing scripts to automate purchase
  • Support more sites
  • Option to choose between Disc/Digital version or both

I'll be adding PRs for this list and add this list somewhere else lol. And for the meantime, I'll review this PR 😁

@stan2474
Copy link
Author

Uh, you know your username and password are displayed in the code, right?

Where?

@@ -0,0 +1,183 @@
import * as puppeteer from 'puppeteer'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How different is this logic from the other target script? If it's mostly the URL, then I feel it's better to include another option in config.json to indicate digital,disc, or both and load the URL based on that. So,

  • we can add another prompt asking user to add device type (digital, disc, or both)
  • we can set scrape-target-util to accept a type argument, which tells us which URL to go to (digi or disc). If user set as both, then we can run scrape-target-util twice, one with the digi argument, the other with disc. This logic will probably be similar to other sites as well.

@mc130h
Copy link

mc130h commented Nov 18, 2020 via email

@mc130h
Copy link

mc130h commented Nov 18, 2020 via email

@eg9y
Copy link
Owner

eg9y commented Nov 18, 2020

Good point. I'm leaning towards enforcing one order only. If there's one item in-stock, then stop the listeners while proceeding with the purchase on that one site, regardless whether it'll succeed or not. If that site fails, then users are expected to manually rerun the script. I think that's pretty fair.

@mc130h
Copy link

mc130h commented Nov 18, 2020 via email

@stan2474
Copy link
Author

stan2474 commented Nov 18, 2020

These are all the things I'm planning:

  • Use a request module with cheerio to scrape the website
  • If on stock, switch to puppeteer chromium which will buy it
  • Add login to Playstation Direct
  • Make target utility accept a type argument

@eg9y
Copy link
Owner

eg9y commented Nov 18, 2020

@mc130h That's fair. Although keep in mind that some sites like Walmart request for Captcha at random times, at least based on my experience, which is why the current code stops before the last purchase order button. Another reason is, I never tried testing the very last order button since I didn't want to actually order the item I was testing on. I'm open to any suggestions on how to handle this type of situation.

@stangithuboffical Last time I checked, cheerio isn't capable of scraping sites with react/angular/etc but I might be wrong. But the rest of the plan sounds good 🙂

@dsalaz04
Copy link

I am running a single Target scrape, and I keep getting the error: Error code: Out of Memory after about 10 minutes of running. 1. Is there any way to prevent this from happening? 2. If there's not a way to prevent it, where do I have to adjust the source to make it reload the page when that happens? In the command prompt, I get "TimeoutError: Navigation timeout of 30000 ms exceeded", so I am thinking instead of displaying this message, just attempt to refresh the page again.

@eg9y
Copy link
Owner

eg9y commented Nov 19, 2020

@dsalaz04 A way to prevent it is to run the browser in headless mode while checking for stock (refer to my above comment). Note that this is still in progress. There are rumors that PS5 will be in-stock in a bunch of site before black friday. It's probably not a good idea to use this for that. Basically the aim is to finalize all this by before BF. Hope you understand

@mc130h
Copy link

mc130h commented Nov 19, 2020 via email

@dsalaz04
Copy link

@dsalaz04 A way to prevent it is to run the browser in headless mode while checking for stock (refer to my above comment). Note that this is still in progress. There are rumors that PS5 will be in-stock in a bunch of site before black friday. It's probably not a good idea to use this for that. Basically the aim is to finalize all this by before BF. Hope you understand

Tried to run headless and it did the same thing. No problem, just pointing it out so the fixes can take that into consideration.

@stan2474
Copy link
Author

I might rewrite the whole thing into nodejs because I know like 15% of typescript

@sabbir109
Copy link

How it wark

@malshoff
Copy link

How it wark

Read the README

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants