Hi everyone,
I hope you can help me with my little problem. I'm trying to extract a float value from a web page. This is the HTML with the float I need:
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"User-Agent: ESP8266\r\n" +
"Connection: close\r\n\r\n");
while (!client.available()){
delay(50);
}
if (client.find("tab_box_val_big")){
Serial.println("Found the specific point!");
while (client.available()){
String line = client.readStringUntil('<');
Serial.println(line);
}
} else{
Serial.println("Specific point not found");
}
If I run this code on the serial monitor, I will see all the code after "tab_box_val_big" till the end, because this parameter '<' is not recognized as a stop (as you can see the < was deleted from the output). Here the output:
Found the specific point!
">92,92
/div>
/div>
...
I think to be close to the solution, just a little push
Thanks in advance for your time!
Have a look at the Serial Input Basics tutorial, which shows you how to extract data surrounded by start and end markers, which in your example could be (if you take some care) '>' and '<'.
Obviously you will have to ignore irrelevant occurrences of those markers, so the solution will be highly specific to this type of message.
With Arduino it is best to avoid the problems caused by use of Strings and instead use the C-string processing functions in the <string.h>standard library.