1

So i wanna scrape a site, but I don't want to do 200 requests at once, maybe 5.

for (i=0; i<=200; i++) {
      asyncFunction() // I want to limit this, so only 10 functions re gettibg called per time
    }
  • what does `asyncFunction()` return? – Jaromanda X Sep 16 '18 at 23:50
  • @JaromandaX it prints stuff depending on the response from a website –  Sep 16 '18 at 23:56
  • 1
    that's not what I asked, I asked **what does it return** . i.e. what does `console.log(asyncFunction())` output – Jaromanda X Sep 16 '18 at 23:59
  • In addition to the one yours has been marked a duplicate of, here are some other references: [Nodejs async request with list of URLS](https://stackoverflow.com/questions/47299174/nodejs-async-request-with-a-list-of-url/47299802#47299802), [https://stackoverflow.com/questions/48842555/loop-through-an-api-get-request-with-variable-url/48844820#48844820](Loop through an API get request with variable URL), [Async method for max requests at a time](https://stackoverflow.com/questions/36730745/choose-proper-async-method-for-batch-processing-for-max-requests-sec/36736593#36736593). – jfriend00 Sep 17 '18 at 01:37
  • Other references: [How to control how many promises access network in parallel](https://stackoverflow.com/questions/41028790/javascript-how-to-control-how-many-promises-access-network-in-parallel/41028877#41028877). In all of these references, you will HAVE to have a means of knowing when the `asyncFunction()` is done. It will have to either return a promise or accept a callback that will tell you when the async operation is done. You can then adapt that to any of the 5 references we've provided for you. – jfriend00 Sep 17 '18 at 01:39
  • Another reference: [Promise.all consumes all my ram](https://stackoverflow.com/questions/46654265/promise-all-consumes-all-my-ram/46654592#46654592) – jfriend00 Sep 17 '18 at 01:41

0 Answers0