Search code examples
javascriptnode.jsweb-scrapingaxioscheerio

How to get backgroundImage url in cheerio


I was trying to get banner of my Anime-Planet account for my scraper system. I tried everything i have know with cheerio but i couldn't get the profileBackgrounds background-image url. Properties

I tried

async function Al() {
  const cheerio = require("cheerio");
  const url = "https://www.anime-planet.com/users/kyoyacchi";
  const {data} = await client.axios.get(url, {
    headers: {
      "User-Agent":
        "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Mobile Safari/537.36",
    },
  });
  const $ = cheerio.load(data);

  return $(".pull-beta.pull-alpha.pullup.editableBanner")
    .find(".wrapper")
    .find("profileBackground");
}
Al();

Here is the result

This one is only returns avatar path.


Solution

  • I learned that it's $('div[id=profileBackground]')