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

153
Views
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 answers
Answer question

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 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!