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

177
Views
pinterest web scrape image

I'm trying to get a url from a pinterest image and send a url of it through the general profile of the user on pinterest, but it's returning me undefined

enter image description here

my code:

const Command = require("../../structures/Command");
const cheerio = require("cheerio");
const rp = require("request-promise");
const { head } = require("request");

module.exports = class Pinterest extends Command {
  constructor(client) {
    super(client);
    this.client = client;

    this.name = "pinterest";
    this.category = "Dono";
    this.aliases = [];

    this.enabled = true;
    this.guildOnly = true;
  }
  async run({ message, args, prefix, author }, t) {
    if (
      message.author.id !== "196679829800747017"
    )
      return;

      const URL = (`https://br.pinterest.com/n1cotin3/_created/`)
      const headerObj = {
          uri: URL
      };
      rp(headerObj)
      .then(html => {
          var $ = cheerio.load(html)

          const avatar = $("#mweb-unauth-container > div > div:nth-child(2) > div:nth-child(3) > div.F6l.ZZS.k1A.zI7.iyn.Hsu > div > div > div > div:nth-child(1) > div:nth-child(1) > div > div > div > div > div > a > div > div > div > div > div.XiG.zI7.iyn.Hsu > img").attr("src")
          console.log(avatar)
    message.react(`💥`);
  })
}
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The problem is that the page is still loading. #mweb-unauth-container > div > div:nth-child(2) doesn't exist, because #mweb-unauth-container > div only has one div child, and it's a loading icon. I don't think this is something you can do with cheerio, you'll have to use an alternative that can resolve Javascript (such as Puppeteer).

Alternatively, if you don't want to scrape, you can use a private API (which, although subject to change at any point, would definitely be more performant):

https://widgets.pinterest.com/v3/pidgets/users/n1cotin3/pins/

Example:

const res = await requestThatEnpointSomehow();
const images = res.data.pins.map(({ images }) => images['564x']);

// `images` will be a list of URLs.
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!