I want to make a http request, get the website content and check one specific element. Currently I'm doing it with lcurl (got explanations from a tutorial). Here is an excerpt of my code:
curl_global_init(CURL_GLOBAL_ALL);
CURL *myHandle;
CURLcode result;
struct BufferStruct output;
output.buffer = NULL;
output.size = 0;
//requested value is on this website
char* url = "https://www.somewebsite.com";
//set curl handle to write the website content into buffer
myHandle = curl_easy_init();
curl_easy_setopt(myHandle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
curl_easy_setopt(myHandle, CURLOPT_WRITEDATA, (void*)&output);
curl_easy_setopt(myHandle, CURLOPT_URL, url);
curl_easy_perform( myHandle );
//searching for position of the requested value.
uint8_t* value_position = strstr(output.buffer, "value_description");
//copy the value (8 chars) into a buffer defined earlier
strncpy(value, value_position, 8);
//... clean up etc.
The code works. But I wonder if this is the fastest way... Any ideas how to do it faster? Thanks alot!