JavaScript Puppeteer js eval function returning an object of objects puppeteer eval function

Currently I have the following partial code in my puppeteer file:

  const getImgSrc = await page.$eval('#ldpGallery', el => el.getElementsByTagName('img'));
  console.log(getImgSrc);

The html I'm getting this from is this:

<img data-src="https://example.com/981489624/e132d90154bc6cbc6616442c0742fc43l-m0xd-w1020_h770_q80.jpg" class="owl-lazy" src="">

The results I get in my console is this:

{ '0': {},
  '1': {},
  '2': {},
  '3': {},
  '4': {} }

I'm trying to access data-src from the above html. After I retrieve the object I tried. forEach() and map and they both give me an error.

How would I get the data-src string?

Answer:1

The best approach is trying to solve everything all the data fetching on the evaluate. You could do something like this:

const getImgSrc = await page.$eval('#ldpGallery', el =>
    Array.from(el.getElementsByTagName('img')).map(e => e.getAttribute("data-src")));
console.log(getImgSrc);
Answer:2

I have created a modal list using bootstrap and Actually I have a form list created and when entered details, it will land me to a desired page. Register button performs this function. But now I have ...

I have created a modal list using bootstrap and Actually I have a form list created and when entered details, it will land me to a desired page. Register button performs this function. But now I have ...

I am attempting to store html code in a textarea field using jquery with the following code: var text ="<p>Hello, my name is Sam</p>"; var textarea = d.createElement( 'textarea' ); // ...

I am attempting to store html code in a textarea field using jquery with the following code: var text ="<p>Hello, my name is Sam</p>"; var textarea = d.createElement( 'textarea' ); // ...

  1. jquery fill textarea value
  2. jquery fill textarea
  3. jquery fill textarea with text
  4. jquery populate textarea

I have this multi dimensional array of objects - const initialArray = [ { name: 'aaa', value:[{id:1, data:1}, {id:2, data:2}, {id:3, data:3}] }, { name: 'bbb', value:[{id:1, data:...

I have this multi dimensional array of objects - const initialArray = [ { name: 'aaa', value:[{id:1, data:1}, {id:2, data:2}, {id:3, data:3}] }, { name: 'bbb', value:[{id:1, data:...

  1. reduce multidimensional array javascript
  2. reduce multidimensional array php
  3. reduce multidimensional array
  4. mpi_reduce multidimensional array
  5. how to reduce multidimensional poverty
  6. matlab reduce multidimensional array

Let's say I have a number input with only a few possible values like the following : <label for="test" translate="entities.test"></label> <input id="test" name="test" type="number" min=...

Let's say I have a number input with only a few possible values like the following : <label for="test" translate="entities.test"></label> <input id="test" name="test" type="number" min=...

  1. display number text
  2. display text and number matlab
  3. display text as number in excel
  4. display text instead of number in excel
  5. excel display text after number
  6. excel display text before number