Hi Team,
I need to extract a src links (more than one) from the JSON response inside the message section. The response looks like below
I tried to use find between, but it only detect one link like below.
I’m sure, there is a better way to extract all the src links from the response. With use of some JSON extractor. Guide me on this.
Could you please show us a code snippet? And the full json object you’re trying to extract such information?
Hi @rdt.one ,
i can able to extract the first img src link with the below code snipper.
let doc = JSON.parse(response.body);
let myhtml= JSON.stringify(doc.message);
const srcs = findBetween(myhtml, ‘<img src='’, “'”);
But there are several links on the same message (myhtml) with the same right and left boundaries. Is there is away to extract all the img links. from the myhtml.
@Gerard yes you should be able to do so via regex. Maybe if you take a look at this can help you.
the html.find() works fine for me
let doc = JSON.parse(res.body);
let myhtml= JSON.stringify(doc.message);
let out=parseHTML(myhtml);
out
.find('img')
.toArray()
.forEach(function (item) {
let temp= item.attr('src').toString();
});
Checking for regex also. Thanks @rdt.one .
1 Like