Hi everybody,
i have try this code for get a value in a online text file but the code display the value charactere by character and display the http requests before.
Can you help me for don't display the http requests and get the value in a string ?
Thank a lot and bests regards
The code :
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char serverName[] = "www.la-referencerie.fr";
EthernetClient client;
void setup(){
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
while(true);
}
Serial.begin(9600);
}
void loop(){
if (client.connect(serverName, 80)) {
client.println("GET /unnicoin/unnicoin.txt HTTP/1.0");
client.println("Host: www.la-referencerie.fr");
client.println();
}
else {
Serial.println("connection failed");
Serial.println();
}
while(client.connected() && !client.available()) delay(1);
while (client.connected() || client.available()){
char data = client.read();
Serial.print(data);
}
client.stop();
}