G
G
Goobert Crypto2020-01-15 20:53:11
JavaScript
Goobert Crypto, 2020-01-15 20:53:11

How is it possible to parse text from a span tag?

5e1f5081ddbae854748731.png
There is a span tag with the aria-label attribute, I have been trying to parse the text from this attribute for a day now, it returns either an object or a string but not the text "Load more comments"))) please help with the code, what's wrong? I will be very grateful to the person who can help me solve this problem.

const puppeteer = require('puppeteer');
(async () => {

  const browser = await puppeteer.launch(/*{headless: false}*/);
  const page = await browser.newPage();
  await page.goto('https://www.instagram.com/p/B7OCywQF4Yu/');
 await page.waitForSelector('span[aria-label="Load more comments"]');
try
{
  const x = page.$eval('span[aria-label="Load more comments"]',erw=>erw.innerHTML)
  console.info( x);
}
 catch(err)
 {
   console.log(err)
 }
  await browser.close();
})();

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Programming, 2020-01-15
teacher @tosrer

= span.ariaLabel

L
Lev Zabudkin, 2020-01-16
@zabudkin

erw=>erw.innerHTML
might be better than
erw=>erw.text
and not bother with tags? ;)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question