Google stock search but for Currency

I am using the ‘GoogleStockSearch’ sketch which works fine for me when I look for a simple stock. However when I look for a currency, the sketch cannot bring it back because there is text in the field.

I think the sketch searches for ’ <span class=“pr”>" ’ and gets what is after the next ‘>’. For a single stock this is fine because it is a number in the source:-

102.25 the number for this stock being 102.25.

however for a currency the same field comes back as :-

1 GBP = 1.6587 USD

you can see there is ‘USD’ in the field which I think is causing an error as the sketch is looking for a ‘float’. The same problem occurs when I search for an index, I presume because it has a ‘,’ in it.

Obviously I want to bring back a string or text or some sort but I do not know how to do this.

I have looked at the textfinder library but I want to keep it more simple for now. I am sure there is a way but I just can’t get it.

Thanks in advance

 * Web Client Google Finance sketch
 * get the stock value for google and write to analog pin 3.

#include <SPI.h>      // needed for Arduino versions later than 0018
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char serverName[] = "";

EthernetClient client;
float value;

void setup()
  if(Ethernet.begin(mac) == 0) { // start ethernet using mac & IP address
    Serial.println("Failed to configure Ethernet using DHCP");  
    while(true)   // no point in carrying on, so stay in endless loop:
  delay(1000); // give the Ethernet shield a second to initialize

void loop()
  Serial.print("Connecting...  ");
  if (client.connect(serverName, 80)>0) {
  client.println("GET //finance?q=aud HTTP/1.0");    
  client.println("User-Agent: Arduino 1.0");
    Serial.println("connection failed");
  if (client.connected()) {
//     if(client.find("<span class=\"pr\">"))  //USED FOR STOCKS
//     if(client.find("<span class=bld>"))   //returns the id of the currency
      if(client.find("1 GBP = <span class=bld>"))  //returns the id of the currency

       client.find(">");  // seek past the next '>'  //USED FOR STOCKS
       value = client.parseFloat();
       Serial.print("Value :");
       Serial.println(value);  // value is printed
      Serial.println("Could not find field");
  else {
  delay(5000); // 5 seconds between each connect attempt

Obviously I want to bring back a string or text or some sort but I do not know how to do this.

The client example shows you how to print the server's response.

There are dozens of horrid examples around of storing the response in a String. It's not even a tiny challenge to use a NULL-terminated array of chars instead.

Once you have the String or string, parsing it is relatively straightforward. Not trivial, in many cases, but not that difficult if the data is well formed.