parse http data from website

Hi,

I am following an example from here:

and trying to parse temperature value from a website such as https://www.wunderground.com.
I understand I should be using API for this project but I am looking to make it work using regular html payload.
Basically, I am trying to extract '43' temperature which is listed after Temperature table cell.
It's not JSON so I am looking for a way to search the payload residing in int httpCode = http.GET(); and only get temperature value.

<tr><td>Temperature</td>
  <td>
  <span class="nowrap"><b>43</b>&deg;F</span>
 </td>
  </tr>[Codebox=html5 file=Untitled.html][/Codebox]

Thanks all

Here is more of payload data

<table><tr><td> <center>
<table border="1" width="100%">
<tr><td colspan="2" ><a name="conditions"></a>
 Updated: <b>1:35 PM </b>
Observed at
<b></b>
 </td></tr>
<tr><td>Temperature</td>
  <td>
  <span class="nowrap"><b>43</b>&deg;F</span>
 </td>
  </tr>
  <tr><td>Windchill</td>
  <td>
  <span class="nowrap"><b>34</b>&deg;F</span>
  </td></tr>
<tr><td>Humidity</td>
<td><b>93%</b></td></tr>
<tr><td>Dew Point</td>
<td>
  <span class="nowrap"><b>41</b>&deg;F</span>
</td></tr>
<tr><td>Wind</td>
<td>
<b>NW</b> at
  <span class="nowrap"><b>23</b>&nbsp;mph</span>
</td></tr>
        <tr>
                <td>Wind Gust</td>
                <td>
  <span class="nowrap"><b>30</b>&nbsp;mph</span>
</td>
        </tr>
<tr><td>Pressure</td>
<td>
  <span class="nowrap"><b>29.52</b>&nbsp;in</span>
  <b>(Falling)</b>
</td></tr>
<tr><td>Conditions</td>
<td><b>Light Rain</b></td></tr>
<tr><td>Visibility</td>
<td>
  <span class="nowrap"><b>10.0</b>&nbsp;miles</span>
</td></tr>
<tr>
        <td>UV</td>
                <td>1 out of 16</td>
</tr>
<tr><td>Clouds</td>
<td>
<b>Mostly Cloudy</b>
(BKN)
:
  <span class="nowrap"><b>1600</b>&nbsp;ft</span>


<b>Mostly Cloudy</b>
(BKN)
:[Codebox=html4strict file=Untitled.html][/Codebox]

It is possible to read the content of a website as a data stream and use the find method to look for a specific string, such as "nowrap">" in your case. When you find this string, you just need to read the 2 following bytes and compute the value of the temperature.

lesept:
It is possible to read the content of a website as a data stream and use the find method to look for a specific string, such as "nowrap">" in your case. When you find this string, you just need to read the 2 following bytes and compute the value of the temperature.

Personally, I'd find the "Temperature" table row, first. There COULD be other instances of "nowrap" present, or added in the future. Make sure you get the correct nowrap instance before you arbitrarily consume the next two bytes.

Yes, that's right.

I recently did something similar to what you want to do. Here is how you can adapt it to your needs:

  WiFiClient *pStream;
  HTTPClient http;
  http.begin(" /* your URL here */ ");
  if (http.GET() == HTTP_CODE_OK) {
    pStream = http.getStreamPtr();
    pStream->find("Temperature");
    while (pStream->find("nowrap\"><b>")) {
      int c1 = pStream->read() - '0';
      int c2 = pStream->read() - '0';
      int temperature = c1*10+c2;
    }
  }

Of course you would need to add at the beginning

#include <WiFi.h>
#include <HTTPClient.h>

Hope this helps (and works :slight_smile: )

Thank you very much lesept!!!

:slight_smile: