Answer the question
In order to leave comments, you need to log in
How to parse SRC of JS images (axios, cherio)?
I am writing a scraper, it should collect information about the car, the situation is such that I took all the text part I needed, but I don’t know how to get the link to the image of the car itself, I’m waiting for your help guys.
Here's what the code looks like on the site from which I take the information:
But I already have such information:
Ideally, I'll give you a link to the picture and you're done.
Here is part of the code:
const axios = require('axios');
const cheerio = require('cheerio');
const { strict } = require('assert');
const express = require('express');
const mongoose = require('mongoose');
const url = 'https://auto.ria.com/uk/car/volkswagen/?page=4';
axios.get(url)
.then(response => {
//console.log(response.data);
getData(response.data)
})
.catch( error => {
console.log(error);
})
let getData = html => {
data = [];
const $ = cheerio.load(html);
$('.content-bar').each((i, elem) => {
data.push({
title : $(elem).find('.head-ticket').text(),
money : $(elem).find('.size22').text(),
characteristic: $(elem).find('.characteristic').text(),
descriptions : $(elem).find('.descriptions-ticket').text(),
link : $(elem).find('a.m-link-ticket').attr('href')
});
});
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question