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

159
Vistas
Get image-urls from imgur link in node js

I need to get the image urls from imgur post urls.

The urls of the posts looks like this: https://imgur.com/gallery/kgfDi

But the image urls look like this: https://i.imgur.com/DWVuwMc.jpeg

I tryed it with the web-scraping library x-ray js but for some reason it doesn't work. For some reason I just get an empty array.

My code (I use Firebase Cloud Functions):

    var Xray = require('x-ray');

    exports.getImgurLink = functions.https.onCall(async (data, context) => {
        var xray = Xray();
    
        xray('https://imgur.com/a/1QEKZ2f', '.image-placeholder')(function (err, res) {
            console.log("res: "+res);
        })
    });

I have the idea with the xray from this Post: Make imgur link have .png or .jpg in the end of the url with nodeJS but it is already older so I am not sure if it still works.

Can someone show me another method to get image urls from imgur or how to fix my xray code?

Thank you for your time.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can use puppeteer to do that. With your example links:

const puppeteer = require('puppeteer')

exports.getImgurLink = functions.https.onCall(async (data, context) => {
    let url = "https://imgur.com/gallery/kgfDi"

    const browser = await puppeteer.launch()
    const page = await browser.newPage()
    await page.goto(url)

    const el = await page.$x('//*[@id="root"]/div/div[1]/div[1]/div[3]/div/div[1]/div[2]/div/div/div[2]/div/div/div/div/div/img')

    el.forEach(async function(element){
        const src = await element.getProperty('src')
        const scrText = await src.jsonValue()

        console.log({ scrText })
    })
});
about 4 years ago · Juan Pablo Isaza Denunciar
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