Process Multiple URLs #130

Closed
opened 2025-10-14 18:13:41 -06:00 by navan · 0 comments
Owner

Originally created by @geraldsamosir on 10/20/2017

Process Multiple URLs

how to use x-ray js for scraping multiple url

at this case all of that url have render to the same dom

can you give me some example ?

if have try like this

  alluri.forEach(function(uri) {
           x(uri,{
            title : '.product-title@text',
            idshop  :'#shop-id@value',
            price  : "span[itemprop='price']",
            detail : "p[itemprop='description']",
            berat  : ".detail-info@text",
            gambar  :"img[itemprop='image']@src"
        })(function(err,obj){
                obj.berat = obj.berat.replace(/\s/g,'') 
                obj.berat =  obj.berat.slice(parseInt(obj.berat.lastIndexOf("Berat") + 5) , obj.berat.lastIndexOf("Terjual"))
                console.log(obj)
         })

that's work but my problem i canot return it as json for my end point

maybe you have another way ?

*Originally created by @geraldsamosir on 10/20/2017* ### Process Multiple URLs how to use x-ray js for scraping multiple url at this case all of that url have render to the same dom can you give me some example ? if have try like this ``` alluri.forEach(function(uri) { x(uri,{ title : '.product-title@text', idshop :'#shop-id@value', price : "span[itemprop='price']", detail : "p[itemprop='description']", berat : ".detail-info@text", gambar :"img[itemprop='image']@src" })(function(err,obj){ obj.berat = obj.berat.replace(/\s/g,'') obj.berat = obj.berat.slice(parseInt(obj.berat.lastIndexOf("Berat") + 5) , obj.berat.lastIndexOf("Terjual")) console.log(obj) }) ``` that's work but my problem i canot return it as json for my end point maybe you have another way ?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github/x-ray#130
No description provided.