Hello Guys! I am having trouble getting data off my website that I am hosting using Google drive. I think I am accessing the website wrongly; any idea how I would get the data off the website? ( I am trying to get the number 1 or the field between the char ":" and "."
This is the website: https://8e8c687742d89531df83dbc0a4bfaefc17c53d42.googledrive.com/host/0B6_Ayl7YnEAIVFVmQk9QanJZTzg/index.html
/*
Based on the work of Tom Igoe and Adrian McEwen
*/
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
char serverName[] = "www.8e8c687742d89531df83dbc0a4bfaefc17c53d42.googledrive.com/";
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;
char inString[32]; // string for incoming serial data
int stringPos = 0; // string index counter
boolean startRead = false; // is reading?
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// 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 /host/0B6_Ayl7YnEAIVFVmQk9QanJZTzg/index.html");
client.println();
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
String pageValue = connectAndRead(); //connect to the server and read the output
Serial.println(pageValue); //print out the findings.
delay(5000); //wait 5 seconds before connecting again
}
String connectAndRead(){
//connect to the server
Serial.println("connecting...");
readPage(); //go and read the output
}
String readPage(){
//read the page, and capture & return everything between '<' and '>'
Serial.println("a");
stringPos = 0;
memset( &inString, 0, 32 ); //clear inString memory
if (client.available()) {
char c = client.read();
Serial.println("a");
if (c == ':' ) { //'<' is our begining character
startRead = true; //Ready to start reading the part
}else if(startRead){
if(c != '.'){ //'>' is our ending character
inString[stringPos] = c;
stringPos ++;
}else{
//got what we need here! We can disconnect now
startRead = false;
client.stop();
client.flush();
Serial.println("disconnecting.");
return inString;
}
}
}
}