Ethernet library - get data from existing server

Hello, I am trying to control a device based on a single value from within a database of values on a website, linked in the next post.

How can I have an Arduino acquire that int value without an additional computer, assuming the Arduino has the Ethernet shield installed and internet connectivity?

Thanks for any guidance.

The link is : http://www.ndbc.noaa.gov/data/5day2/44013_5day.txt

and I am specifically seeking the average wave period from the most recent entry on this text only page. It is the 10th column, DPD, and the third row.

If you do a GET on that url, the whole text file will be streamed back to you. With luck, it will be easy to recognize line breaks. Collect the data from one break to the next in a String. When the line break occurs, copy the String object to another String, and keep reading. When there is no more data to read, the last copy contains the last line.

Parsing that line is easy enough.

You can do something like below, but you need to make a simple way to just capture the line you want, as the total file is too big for a string.

//zoomkat 12-21-10
//simple ethernet client test code
//for use with IDE 0021 and W5100 ethernet shield
//modify the arduino lan ip address as needed
//open serial monitor to see what the arduino receives
//push the shield reset button to run client again

#include <SPI.h>
#include <Ethernet.h>
String readString, readString1;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 102 };
byte server[] = { 140, 90, 238, 27 }; // nnoah

Client client(server, 80);

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  Serial.println("starting simple arduino client test");
  Serial.println();
  Serial.println("connecting...");

  if (client.connect()) {
    Serial.println("connected");
    client.println("GET /data/5day2/44013_5day.txt HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
    //readString += c;
  }
        
  if (!client.connected()) {
     client.stop();
    
    //Serial.print(readString);
    Serial.println();
    Serial.println();
    
    /*
    int d1 = readString.indexOf('<'); 
    int d2 = readString.indexOf('>'); 
    readString1 = (readString.substring(d1+1,d2));
    
    Serial.println("==================================");
    Serial.println("data from server:");
    Serial.println();
    Serial.println(readString1);
    Serial.println();
    Serial.println("==================================");
    Serial.println();
    */     
    Serial.println("done");
    for(;;);
    
    }
 }

The below seems to do what you need. The whole file is received with just the dsired part saved. The code counts the line feeds until the desired line is reached, then that line is captured into a string. That string is then parsed to get the wave period value.

//zoomkat 12-22-10
//simple ethernet client test code
//for use with IDE 0021 and W5100 ethernet shield
//modify the arduino lan ip address as needed
//open serial monitor to see what the arduino receives
//push the shield reset button to run client again

#include <SPI.h>
#include <Ethernet.h>
String readString, readString1;
int x=0;
char lf=10;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 102 };
byte server[] = { 140, 90, 238, 27 }; // NOAA

Client client(server, 80);

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  Serial.println("starting simple arduino client test");
  Serial.println();
  Serial.println("connecting...");

  if (client.connect()) {
    Serial.println("connected");
    client.println("GET /data/5day2/44013_5day.txt HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    //Serial.print(c);
    if (c==lf) x=(x+1);
    if (x==14) readString += c;
    //readString += c;
  }
        
  if (!client.connected()) {
     client.stop();
    
    Serial.println("Current data row:" );
    Serial.print(readString);
    Serial.println();
    readString1 = (readString.substring(41,43));
    Serial.println();
    Serial.print("DPD sec: ");
    Serial.println(readString1);
    Serial.println("done");
    
    for(;;);
    
    }
 }

Thanks zoomkat and Paul. That really gets me on the right track.