Data from html web page in label of AI2

is it possible to take a value from a webpage online and put a value of it in a label?

for example from this webpage:

i want to take the value inside this tag


and this value:


and put them in 2 labels/ textbox

but it's not good for me..

i need text after span class="t-text -black-warm-60 -formatPrice">

and before ** /strong>

Label1 with Property HTMLFormat enabled



the js:

window.AppInventor.setWebViewString(document.getElementsByClassName("t-text -black-warm-60 -formatPrice")[0].innerText + "|"+document.getElementsByClassName("t-text -size-lg -cbalanced -percPrice")[0].innerText)
1 Like

this is Magic! :slight_smile:
thanks also to Juan_Antonio

(added to FAQ)


i saw that the name of class change..

if it is with +
window.AppInventor.setWebViewString(document.getElementsByClassName("t-text -black-warm-60 -formatPrice")[0].innerText + "|"+document.getElementsByClassName("t-text -size-lg -cbalanced -percPrice")[0].innerText)

while if it is -
window.AppInventor.setWebViewString(document.getElementsByClassName("t-text -black-warm-60 -formatPrice")[0].innerText + "|"+document.getElementsByClassName("t-text -size-lg -assertive -percPrice")[0].innerText)

and it changes in a day a lot of times

while if i want also to add last update i tryed adding
window.AppInventor.setWebViewString(document.getElementsByClassName("t-text -black-warm-60 -formatPrice")[0].innerText + "|"+document.getElementsByClassName("t-text -size-lg -assertive -percPrice")[0].innerText+ "|"+document.getElementsByClassName("t-text -block -size-xs | -xs")[0].innerText)

and it's ok!

is it possible to split in 3 labels the 3 values at fly? and not add before in 1 label with "|" ?

you can use any special character as seperator, and use split at block to convert the outcome to a list , then pick item from the list.

tryed this

select list item from first, not ITXXXXX

yes i corrected it with first!! my fault

can i do also operations after retrieved data?

for example i have a value in my labe8
and i want to do a subtraction (-) between 2 labels
label 8 - label27 retrieved from html

the values are correct

i replaced , with . and works

is there other way to fix? and use the , ?

in app inventor, even in Math world, comma ','is not part of number.

in italy we use , for decimal numbers in math!
anyway i will use . :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.