fetching a web page but discarding header data
Posted: Wed Nov 25, 2015 5:36 pm
hello,
I am using the following function to grab the contents of a web page but would like to make it get rid of all the header data before returning. Dose any one have a simple way of doing this? I only am trying to get the contents of the page it self. None of the other junk.
I am using the following function to grab the contents of a web page but would like to make it get rid of all the header data before returning. Dose any one have a simple way of doing this? I only am trying to get the contents of the page it self. None of the other junk.
Code: Select all
String FetchWebUrl(String URLtoGet)
{
String str;
String ServerToConnectTo;
String PageToGet;
ServerToConnectTo = URLtoGet.substring(0, URLtoGet.indexOf("/"));
PageToGet = URLtoGet.substring(URLtoGet.indexOf("/"));
Serial.println(ServerToConnectTo);
Serial.println(PageToGet);
WiFiClient client;
if (client.connect(ServerToConnectTo.c_str() , 80))
{
client.print(String("GET " + PageToGet + " HTTP/1.1\r\nHost: " + ServerToConnectTo + "\r\n\r\n"));
delay(100);
str = "";
while (client.available())
{
str += String((const char)client.read());
delay(0);
}
return str;
}
return "";
}