Read from HTML code

Hi, I need to read an HTML page of a relays for use as button label and button status


<div>
<font size="5"> Room1<span style="color:red">0 </span> </font>
<br />
<br />
<br />
<font size="5"> Room2<span style="color:red">0 </span> </font>
<br />
<br />
<br />
<font size="5">Room3<span style="color:red">0 </span> </font>
<br />
<br />
<br />
<font size="5">Room4<span style="color:red">0 </span> </font>
<br />
<br />
<br />
<font size="5">Room5<span style="color:red">0 </span> </font>
<br />
<br />
<br />
<font size="5">Room 6<span style="color:red">0 </span> </font>
<br />
<br />
<br />
<font size="5">Room 7<span style="color:red">0 </span> </font>
<br />
<br />
<br />
<font size="5">Room 8<span style="color:red">0 </span> </font>
</div>

<div>
<p hidden>
Status: 0 0  0 0  0 0  0 0 
Relay1: Room 1
Relay2: Room 2         
Relay3: Room 3   
Relay4: Room 4                              
Relay5: Room 5
Relay6: Room 6                             
Relay7: Room 7                          
Relay8: Room 8
</p>
</div>

How I can read? I've don't found any solution...
Best regards

Use the web component, set the url property and call the Get method, then receive the html page in the GotResponse event

Taifun

1 Like

How I can read from <p hidden> any row? There is a component?

Thanks

There is a technique called Web Scraping for that.

Search this board.

Example:

<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<head>
<title>DemoScrape</title>
<style>
</style>
</head>
<body>
	<h2>Some p elements</h2>
	<p>Hello</p>
	<p>World</p>
	<p>the next one is hidden</p>
	<p hidden>Greetings</p>
</body>
</html>

var parasHidden = [ ];
var paras = document.querySelectorAll('p[hidden]');
for(var i = 0; i < paras.length; i++) {
parasHidden.push(paras[i].innerHTML);
}
var hidps = JSON.stringify(parasHidden);
window.AppInventor.setWebViewString(hidps);

image

1 Like

Thanks I've used Web with list and segment test for retrieve what I need.

Best regards

Be good if you showed an example of this method here ...

Sorry it’s late here, tomorrow I share my solution. Maybe not the best but it is ok for the result.

Regards

This is my solution

Best regards

Does this return the values you would see on the rendered html page ? (even though I realise your paragraph element is hidden)

I don't need to render this value in a webpage but retrieve from a get and use text/background of multiple buttons.

I don't know what that means, but if it works for you...

This is similar to the Taifun parse procedure, but terminates by length instead of by marker.

The returned values might need trimming of their tail ends.

Yes, the number of characters are always the same and I can use this procedure. I clean the unused "Ralay #:" and I remove white space.