Fetch and select data from website with GET

I have a php file what show only a number from 1,2,3 or 4.

If want to make a function to: if the php file give 1 == Serial.println(“It is 1”); if the php file give 2 == Serial.println(“It is 2”); …etc…

I can make a GET with ethernet shield (W5500) but I don’t know how to identifi the content of website/php file. Is there any method or code to do it?

I tried some examples from the forum and I think thats old because not works. Thank you.

post your the code of your best effort and people will help you. If you know how to use GET, the response back will be the contents that you will have to read and parse.

It’s my code:

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char server[] = "www.energy.jullich.com";    
IPAddress ip(192, 168, 0, 177);
IPAddress myDns(192, 168, 0, 1);
EthernetClient client;


unsigned long beginMicros, endMicros;
unsigned long byteCount = 0;
bool printWebData = true; 

void setup() {


  Serial.begin(9600);
  while (!Serial) {
    ; 
  }

  // start the Ethernet connection:
  Serial.println("Initialize Ethernet with DHCP:");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // Check for Ethernet hardware present
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
      while (true) {
        delay(1); // do nothing, no point running without Ethernet hardware
      }
    }
    if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected.");
    }
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip, myDns);
  } else {
    Serial.print("  DHCP assigned IP ");
    Serial.println(Ethernet.localIP());
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);


  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    // Make a HTTP request:
    client.println("GET /teljesitmeny.php HTTP/1.1");
    client.println("Host: www.energy.jullich.com");
    client.println("Connection: close");
    client.println();
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
  beginMicros = micros();
}

void loop() {


  int len = client.available();

    byte buffer[80];
    if (len > 80) len = 80;
    client.read(buffer, len);
  
      Serial.write(buffer, len); // show in the serial monitor (slows some boards)
    

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    endMicros = micros();

    client.stop();


    while (true) {
      delay(1);
    }
  }
}

I look the header, some number (I don’t know what is is), the number what I want and an other number what I don’t know what is it.

That code could not have produced that output. That code will only read a maximum of 80 bytes yet your output shows much more than that.