Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

268
Views
How to get img src URL's from id's children tag with cheerio

I want to get specific's id's children image src data. With cheer.io I can get HTML data from it with $("#descTemplate").html(); code, but I want to get it's html codes children's all of image data.

So I tried $("#descTemplate").find('img').attr('src'); code but it only returns undefined Either $("#descTemplate").html().find('img').attr('src'); code returns nothing.

let searchUrl = 'URL ADDRESS';
await got(searchUrl, {
  timeout: {
    request: 30000,
  },
}).then(async(response) => {
  const $ = cheerio.load(response.body); // HTML data
  // itemDetailImage = $("#descTemplate").html(); // Get HTML part data (Successfully get HTML file)
  itemDetailImage = $("#descTemplate").find('img').attr('src');   // return undefined
  console.log(itemDetailImage);
})

[console.log(itemDetailImage)]

<div style="text-align:center;">
    <img src="//127.0.0.1/upload/1647265117250_378688.jpg" data-ke-src="//127.0.0.1/upload/1647265117250_378688.jpg" alt="">
    <img src="//127.0.0.1/upload/1647265118130_300066.jpg" data-ke-src="//127.0.0.1/upload/1647265118130_300066.jpg" alt="">
    <img src="//127.0.0.1/upload/1647265118350_681553.jpg" data-ke-src="//127.0.0.1/upload/1647265118350_681553.jpg" alt="">
    <img src="//127.0.0.1/upload/1647265118885_854027.jpg" data-ke-src="//127.0.0.1/upload/1647265118885_854027.jpg" alt="">
    <img src="//127.0.0.1/upload/1647265119412_530569.png" data-ke-src="//127.0.0.1/upload/1647265119412_530569.png" alt="">
    <img src="//127.0.0.1/upload/1647265119594_158186.jpg" data-ke-src="//127.0.0.1/upload/1647265119594_158186.jpg" alt="">
    <img src="//127.0.0.1/upload/1647265119973_110062.jpg" data-ke-src="//127.0.0.1/upload/1647265119973_110062.jpg" alt="">
</div>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It looks like it's not there, but you can try:

$("#descTemplate img").get().map(img => $(img).attr('src'))
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!