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

158
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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