dimanche 27 janvier 2019

if statement JavaScript - web scrape clean up

I've Webscraped a Table - i need some information added into the output The output is .xlsx

I've added some Javascript to help clean up unwanted data in the diffrent columns.

var cleanup = function(results) {

 $.each(results, function(){

 this.values[0] = this.values[0].replace("Submission date: ", 
 "").split(" ")[0];
 var d = this.values[0].slice(0, 10).split('-'); 
 this.values[0] = d[1] +'/'+ d[2] +'/'+ d[0];
 this.values[1] = this.values[1].replace("Case number: ", "");
 this.values[2] = this.values[2];
 this.values[3] = this.values[3];
 this.values[4] = this.values[4];
 this.values[5] = this.values[5];
 this.values[6] = this.values[6].replace("Complaint(s) processed - 
 subject to seller's counter notification", "Infringement Proessed");
 this.values[7] = this.values[7].replace("Check complaint 
 details","Details");
 this.values[8] = this.values[8];
 this.values[9] = this.values[9];
});

return results;  
};

the script loops thru the diffrent columns and replaces data. This is the current output

(col1)01/23/2019 (col2)201901221755500580 (Col3)empty write here (Col4)Icon Workspace Co., Ltd.(59090581) (col5)alibaba.com/product-detail/_60833145996.html (col6)Alibaba.com (col7)Submitted (Col8)Details (col9)Visu Lounge Chair (Visu Lounge Chair)

Column 3 is empty since the table that is scraped dosen't show the desired information. i need column 3 to show IP Reg NR: of the specific product.

Column 9 shows which product has been removed.

Can i somehow add a script that writes in not only the column but also the specific rows.

this.values[9] if XXXX then write in this.values[3] XXXX

something like this perhaps?

Aucun commentaire:

Enregistrer un commentaire