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

148
Views
Extraiga el enlace de origen de las etiquetas <img> cuando se proporciona una URL usando Javascript (Dirigido a la página de publicaciones de Facebook)

¿Hay algún método por el cual pueda obtener la URL dentro de la etiqueta <img> desde un enlace?

Por ejemplo: cuando doy un enlace de un sitio web, como un sitio web o una página de Facebook, quiero obtener todas las URL dentro de todas las etiquetas img en ese sitio --> <*img src="url">

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

0

Primero envíe una solicitud a una página, obtenga el contenido y analícelo en html. Luego obtenga todas las etiquetas img usando el método getElementsByTagName .

Por ejemplo, si desea obtener todas las etiquetas img en https://jsonplaceholder.typicode.com , su código debería ser como el siguiente.

 fetch('https://jsonplaceholder.typicode.com').then(function (response) { // The API call was successful! return response.text(); }).then(function (html) { // Convert the HTML string into a document object var parser = new DOMParser(); var doc = parser.parseFromString(html, 'text/html'); var imgTags = doc.getElementsByTagName("img"); console.log(imgTags); var imgTagArr = [...imgTags]; imgTagArr.forEach(img => console.log(img.src)); //iterate the all img tag srcs }).catch(function (err) { // There was an error console.warn('Something went wrong.', err); });

Salida de ejemplo:

json

about 4 years ago · Juan Pablo Isaza Report

0

Sí, en Html como <img class="pqr" url ="xxxxxxx-yyy"/>
en el archivo Js:

 const img =document.querySelector('.pqr') img.src // <-- this will give the src of the image
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!