I want to parse this HTML source and add the values under the "image_description" and "image_caption" tags to an array, but am having trouble working with the source.
Thanks.
A:
Solution:
Parse source HTML
For each img tag, get the src value
Convert the src value to an object
Use regex to extract the information you are looking for
You can use the DOMParser for that.
const parser = new DOMParser();
const domSource = `
Let's be more productive
`;
const htmlDoc = parser.parseFromString(domSource, "text/html");
const imgs = [];
for (let img of Array.from(htmlDoc.querySelector ac619d1d87
Related links:
Comments