Reading from web to serial

I am fairly new to Arduino and am looking to simply read a number from a web API request to the Serial - using the Ethernet shield.

This thread is similar but I can't work out what is going wrong: http://forum.arduino.cc/index.php?topic=115442.0

Basically i am trying to print the number from this URL: http://serve.getinvited.to/the-web-is/get/ to the Serial. I have tried amending the WebClient example code to point to that URL but it simply prints: connected, disconnecting.

Any pointers gratefully received

How far have you got? Do you understand the difference between text and binary numbers? Do you understand what a comms protocol is?

At the moment it sounds like you are doing the equivalent of sending a request for cash to a random address looked up in a phone book. The recipient is likely to look at it, say wtf? and then bin it. If a particular URL implements a data service then there would usually be some kind of protocol you need to follow.

[Edit] I’ve no idea what that URL is, but I just tested it. The URL seems to be using the HTTP protocol and serves up a page consisting of a single digit in ASCII format. You should be able to transfer this directly to any print device, or convert it to a binary number by subtracting 0x30 (from each digit if more than one).

Thank you for your response Don,

That number printed on the site is what I am looking to replicate in the serial. Like this example code which reads a JSON feed.

/*
  DNS and DHCP-based Web client 
 
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13 
 */

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

// Enter a MAC address for your controller below.
byte mac[] = {  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
char serverName[] = "www.nfl.com";


String location = "/~liveupdate/scorestrip/scorestrip.json HTTP/1.0";

// Initialize the Ethernet client library
EthernetClient client;

void setup() {
  // start the serial library:
  Serial.begin(9600);
  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  
  if (client.connect(serverName, 80)) {
    Serial.println("connected");
    // Make a HTTP request:
    client.println("GET www.nfl.com/liveupdate/scorestrip/scorestrip.json HTTP/1.0");
    client.println();
  } 
  else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}

void loop()
{
  // if there are incoming bytes available 
  // from the server, read them and print them:
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    while(true);
  }
}
    client.println("GET www.nfl.com/liveupdate/scorestrip/scorestrip.json HTTP/1.0");

The server name is NOT part of the GET request. The GET request is sent the server. The server knows its name. You really don't need to tell it that.

That code DOES seem to work though for that particular request. But NOT for my request : http://serve.getinvited.to/the-web-is/get/

Still at a loss!

That code DOES seem to work though for that particular request. But NOT for my request

I'm not going to click on a link that I don't trust to see what is actually happening. Does serve.getinvited.to host multiple domains? If so, you need a Host: line to identify your host name.

simple code that will probably does something similar to what you want.

//zoomkat 5-13-13
//simple client test
//for use with IDE 1.0
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields

#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
char serverName[] = "web.comporium.net"; // zoomkat's test web page server
EthernetClient client;

String readString, readString1;
int x=0; //for counting line feeds
char lf=10; //line feed character
//////////////////////

void setup(){

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }
  Serial.begin(9600); 
  Serial.println("Better client test 5/13/13"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendGET(); // call sendGET function below when byte is an e
    }
  }  
} 

//////////////////////////

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(serverName, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.1"); //download text
    client.println("Host: web.comporium.net");
    client.println("Connection: close");  //close 1.1 persistent connection  
    client.println(); //end of get request
  } 
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
    Serial.print(c); //prints raw feed for testing
    if (c==lf) x=(x+1); //counting line feeds
    if (x==9) readString += c; //building readString
   }

  Serial.println();  
  Serial.println();
  Serial.print("Current data row:" );
  Serial.print(readString); //the 10th line captured
  Serial.println();
  readString1 = (readString.substring(0,8)); //extracting "woohoo!"
  Serial.println();
  Serial.print("How we feeling?: ");
  Serial.println(readString1);
  Serial.println();      
  Serial.println("done");
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  readString = ("");
  readString1 = ("");  
  client.stop(); //stop client
}