“buscar memes do Redit de JavaScript” Respostas de código

buscar memes do Redit de JavaScript

axios
    .get(mainUrl)
    .then((response) => {
        dealWithData(response.data);
    })
    .catch((err) => {
        console.log(err);
    });
Selfish Snake

buscar memes do Redit de JavaScript

<img alt="Post image" class="_2_tDEnGMLxpM6uOa2kaDB3 ImageBox-image media-element _1XWObl-3b9tPy64oaG6fax" src="https://preview.redd.it/g64fe51e6z851.jpg?width=640&crop=smart&auto=webp&s=c5917f6…" style="max-height: 512px;">
Selfish Snake

buscar memes do Redit de JavaScript

const randNo = (limit) => {
    const thatNo = Math.floor(Math.random() * limit);
    return thatNo;
};
Selfish Snake

buscar memes do Redit de JavaScript

const dealWithData = (html) => {
    const $ = cheerio.load(html);
    const urlMeme = $("._2_tDEnGMLxpM6uOa2kaDB3.ImageBox-image.media-element._1XWObl-3b9tPy64oaG6fax");
    const indexValue = 0;
    console.log(`Source is:\n${urlMeme[indexValue].attribs.src}`);
};
Selfish Snake

buscar memes do Redit de JavaScript

const indexValue = randNo(urlMeme.length);
Selfish Snake

Respostas semelhantes a “buscar memes do Redit de JavaScript”

Perguntas semelhantes a “buscar memes do Redit de JavaScript”

Mais respostas relacionadas para “buscar memes do Redit de JavaScript” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código