I extracted product names and product prices with xray module of nodejs. While I was scraping, some htm lexpressions like /n comes with text. I want to replace all html codes and create objects with replaced versions.
I have codes like this:
var Xray = require('x-ray')
var x = Xray()
var urls=['link','link','link']
for(var i = 0; i < urls.length; i++){
x(urls[i], {
title: '#sp-title',
price: '.lastPrice'.replace(/(<([^>]+)>)/ig,"").trim()
})(function(err, obj) {
console.log(obj);
})
}
The example code above takes data from the loop of 3 different links and saves as an object and output is as follows.
{
title: 'King P 1110 Exotic Katı Meyve Sıkacağı',
price: '\n 549,00 TL '
}
{
title: 'Xiaomi Mi Pro 10000 mAh Type-C Taşınabilir Şarj Cihazı',
price: '\n 144,14 TL '
}
{
title: 'Fakir River Çay Makinesi',
price: '\n 505,50 TL '
}
Also, how can I check whether an element exist on this page?
Thanks.