Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

154
Vistas
How can I read an external image src?

I need to extract an image src URL from an external website. For example from this URL: enter link description here

the source image URL of interest is img id = "cur-moon" and then assign the image URL to one of my HTML img tag. The reason I need this function is that the image source url (of id "cur-moon") will change over time.

So far I've seen a lot of examples to get it from within the same HTML code itself, not from an external web page.

Solution: Never mind. I managed to get it with bash script commands which eventually download the correct Moon phase image from the website. The image will be referenced to by my websites. These are the commands:

# to search for /scripts/moon.php?i=0.288&p=4.628&r=4.600
# find keyword "id=cur-moon src=" and get all next characters till found " but not including "
x=$(wget -O - https://www.timeanddate.com/moon/phases/thailand/bangkok | grep -oP 'id=cur-moon src="\K[^"]+')
# replace amp; with null; so get /scripts/moon.php?i=0.288&p=4.628&r=4.600
y=$(echo $x | sed 's/amp;//g')
echo https://www.timeanddate.com${y}
# saving current moon phase image (phase is correct, but it always orients vertically)
wget -O moonphase.png https://www.timeanddate.com${y}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda