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?
EDIT: Okay, more explanations: I do run this program in a loop, in my program the url parameter is changing slightly every time, trying lots of websites, not just one. The content I get is plain html. I want to request and check the value on as many websites per second as possible. I hope that information is helpful :)