Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

156
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda