How to do data scraping using JavaScript

@bs113256
something like this

function e(){
 //get all the rows
msgList = document.getElementById("messages-list")
boxes = msgList.querySelectorAll('[id^="content"]:not([hidden])')

dictJoined = "";
//loop all rows
for (let i = 0; i < boxes.length; i++) {
var dict = {};
dict["field1"] = "test1";
dict["field2"] = "test2";

if (dictJoined === ""){
	dictJoined = JSON.stringify(dict);
} else {
	dictJoined = dictJoined + "," + JSON.stringify(dict);
}
}
return "["+dictJoined+"]";
}

this will return a string that looks something like this
[{"field1":"result1","field2":"result2"},{"field1":"result1","field2":"result2"}]

now use
newtonsoft.json.jsonconvert.deserializeObject(of datatable)(javascriptResult)

to convert the result to a datatable!

2 Likes