images-scraper icon indicating copy to clipboard operation
images-scraper copied to clipboard

The "url" argument must be of type string. Received undefined

Open nitsanasraf opened this issue 3 years ago • 2 comments

I am trying to scrape a bunch of categories, and after like 3 images, I get this error and it stops the agent from scraping more.

It does work when I don't use many categories, and for some queries, it works, so overall not stable at all for some reason.

That's my code:

const Scraper = require("images-scraper");

const google = new Scraper({
  puppeteer: {
    headless: false,
  },
});

const categories = ["shark", "cat", "lion", "snake", "spider"];

(async () => {
  try {
    const results = await google.scrape(categories, 10);
    results.forEach((item, index) => {
      item.images.forEach((img, i) => {
        //do something with images
      });
    });
  } catch (e) {
    console.log("Scraping failed", e);
  }
})();

nitsanasraf avatar Dec 28 '21 20:12 nitsanasraf

I get this issue from time to time too. Any progress?

alexandrosmagos avatar Jun 16 '22 00:06 alexandrosmagos

Sorry I can't really reproduce it. Can you provide an OS and version? Can you also describe what happens when it doesn't work?

pevers avatar Jul 07 '22 18:07 pevers

image its random

ghost avatar Dec 02 '22 19:12 ghost

I got the same error, and I fixed that here https://github.com/pevers/images-scraper/pull/107

EliuTimana avatar Jun 25 '23 00:06 EliuTimana

I also got the same issue

Dharmendra016 avatar Jan 11 '24 14:01 Dharmendra016

@pevers can we get an npm release for the fix?

kanjieater avatar Jan 21 '24 14:01 kanjieater

@pevers can we get an npm release for the fix?

I just did the release. Thanks for reminding me and sorry for the delay

pevers avatar Jan 21 '24 14:01 pevers