Answer the question
In order to leave comments, you need to log in
How to get data from a string as an array?
I get a response in my node.js application as a string with html markup. I need to pull out all "sms = [ ... ]" from there, and so that I can work with this data.
Here is part of the function's response:
<body>
// . . .
<script language="javascript">
sms= ["","","","","","","","","","","","","","","","","","","","какой-нибудь текст"];
sms_row_insert(l2_sms_store, sms, pos, 2);
sms= ["текст текст текст","текст 2.","Текст 3","Ещё текст"];
sms_row_insert(l3_sms_store, sms, pos, 3);
sms= ["1","2","3","4","5","","","","","",""];
sms_row_insert(l6_sms_store, sms, pos, 6);
</script>
</body>
Answer the question
In order to leave comments, you need to log in
1. You need to parse the document, for example using https://www.npmjs.com/package/parse5
2. Extract the text of the desired script from html.
3. Run this script in a new context by slipping it into the global object a function called sms_row_insert
https://nodejs.org/dist/latest-v16.x/docs/api/vm.h...
4. Into the inline function 2 the necessary data will come as an argument, they can be collected in an array and processed after the script is executed, or processed for each function call.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question