I have an allure report webpage that provides a dashboard with a percentage on it. I have to create a completely separate webpage which should show that percentage.
How can I pull that div from that page?
Here's the picture of a div
CodePudding user response:
Fetch it, and then parse it until you have the contents of that div.
For fetch, something simple like (polyfill fetch or use axios instead if using nodejs):
fetch('https://jsonplaceholder.typicode.com').then(function (response) {
// The API call was successful!
return response.text();
}).then(function (data) {
// This is the HTML text from our response
console.log(data);
}).catch(function (err) {
// There was an error
console.warn('Something went wrong.', err);
});
And then for parsing, answers like this will be helpful: