Link to home
Start Free TrialLog in
Avatar of Ayman Amine
Ayman Amine

asked on

Scrapping with x-ray node js

I'm a complete beginner so I may have made some stupid mistakes. I made this script with x-ray to scrape user's phone number pictures from different website pages. The script was working very well until it reaches a page where the user didn't put his number in the page and the script stops.

How can I make it continue to the next page even if the phone number doesn't exist? and is there a way to make the script save the pictures directly to my computer instead of giving me the links?
 const Xray = require('x-ray');
const requesst = require('request');
const fs = require('fs');

const xray = Xray()

xray('https://www.marocannonces.com/categorie/350/Appareils-photos,-caméscopes/annonce/6503723/Nikon-D40x-objectif-18-135mm.html', 'div.infoannonce', [{
	numero: '#phone_number img@src',
	nom: '.infoannonce dd',
}])

.paginate('a.next_ad_link@href')
.write('results.json'); 

Open in new window

This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.