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

257
Views
How to get css background image url in NodeJS and Express

I came to know we cannot use getComputedStyle in Node environment because that's a browser behavior.

However, I wanted to get all the background image urls in Node and download them like so

const divs = document.querySelectorAll("div");
Array.from(divs).filter((div) => {
    let backgroundImage = window.getComputedStyle(div).getPropertyValue("background-image");

But I cannot do that.

How to get all the divs having background-image url as styles in NodeJS?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Use a headless browser like puppeteer to render the webpage. Extract all the information you need from the browser and send it back to Node.js. I think this will help.

Regards, omi

about 4 years ago · Juan Pablo Isaza Report

0

const divs = document.querySelectorAll("div");
const backgroundImages = divs.map(div=>div.style.backgroundImage)
console.log(backgroundImages)
// Output: ['url("https://www.image.com/profil.png")','url("https://www.image.com/profil2.png")']
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!