Hello there!
I’m in the need of somehow downloading a .htm page from a website and parse the information from it. I just don’t know how to get the HTML downloadet!
The code I’ve quickly made looks like this, and just returns a 200 OK response from the server.
TCPClient client;
void setup(){
Serial.begin(9600);
Serial.println("Hello there!");
Serial.println("I'm now ready");
while(!Serial.available());
Serial.println("Sure thing. Loop Commencing.");
client.stop();
}// Setup
void loop(){
Serial.println("Trying to connect");
// Keeps looping till we are connected to Prodomus
if(client.connect("prodomus.dk", 80)){
Serial.println("Connected");
int l = client.available();
if(l > 0){
Serial.print("There is ");
Serial.print(l);
Serial.println(" data from the server");
// Now let's print it to serial
for(int i = 0; i < client.available(); i++){
Serial.println(client.read());
}// for
}
Serial.println("Trying to use GET now");
client.println("GET /dk/ledige_lejligheder/lejligheder/2_vaer.htm HTTP/1.1");
client.println("Host: www.prodomus.dk");
client.println("Connection: Keep-Alive");
client.println();
delay(1000);
unsigned int k = client.available();
if(k > 0){
Serial.print("There is ");
Serial.print(k);
Serial.println(" byte data from the server");
// Now let's print it to serial
for(int i = 0; i < k; i++){
Serial.print(char(client.read()));
}// for
Serial.println("");
Serial.println("---------------------------------");
} else {
Serial.println("Nothing in the mail today.");
}
client.stop();
delay(3000);
}// if
}// loop
I’m relatively new to the spark enviroment, but I’m used to Arduino and Processing. In processing it’s a simple loadStrings(address) command
I home someone can help!