I want to scrape the HTML from this website using the Particle Photon:
http://www.espn.com/college-football/game?gameId=400945016
Here is the code that I am running:
#include <HttpClient.h>
unsigned int nextTime = 0; // Next time to contact the server
HttpClient http;
http_header_t headers[] = {
{ "Accept" , "*/*"},
{ NULL, NULL } // NOTE: Always terminate headers will NULL
};
http_request_t request;
http_response_t response;
void setup() {
Serial.begin(9600);
}
void loop() {
if (nextTime > millis()) {
return;
}
Serial.println();
Serial.println("Application>\tStart of Loop.");
request.hostname = "www.espn.com";
request.port = 80;
request.path = "/college-football/game?gameId=400945016";
// Get request
http.get(request, response, headers);
Serial.print("Application>\tResponse status: ");
Serial.println(response.status);
Serial.print("Application>\tHTTP Response Body: ");
Serial.println(response.body);
nextTime = millis() + 10000;
}
If you go to the actual url and look at the page source, you see that it is pretty extensive. However, if with the code that I am running, this is all I get:
Application> Start of Loop.
Application> Response status: 200
Application> HTTP Response Body:
<!DOCTYPE html>
<html class="no-icon-fonts">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="x-ua-compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="initial-scale=1.0, max
Any ideas as to why I am not getting the entire source code?
The truth of the matter is, I just need to grab the team scores from the web page. I was thinking the best way to do this was to read all of the HTML code into a string and parse it to get the scores. Maybe there is a better way to do this, like look through the page and grab certain code? thanks.