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

144
Views
Find every src value in a webpage that contains certain text javascript

I want to find and "console.log" every src value in an HTML page that has a certain text; for example (dam/etc/vsvs). Is it possible to do it with javascript and in the console, as I'm not able to reach to source code of the page? I'm not a developer just trying to find the images I want and list them.

Any help will be appreciated.

Thanks in advance.

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

0

As far as I understand, you have an HTML page and you need to grab every src value which meets some expectations (i.e. starts with smth, includes smth).

So, if you are able to run a script on the page then you can recursively go node by node and check if it has an src attribute.

const findSrc = (node) => {
  const attributesToCheck = ['src', 'srcset', 'data-srcset']

  const srcs = attributesToCheck.map(name => {
    const attr = node.getAttribute(name)

    // here is a condition for your match
    return attr?.startsWith("/etc") ? attr : false
  }).filter(Boolean)

  if (node.children) {
    return srcs.concat(Array.from(node.children).flatMap(findSrc));
  }

  return srcs;
};

console.log(findSrc(document.body));
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!