Ich habe es wie folgt gelöst (vvlt. ja hilfreich für andere). Das curl command line tool bietet die option --libcurl die den entsprechenden code erzeugt der durch die Abfrage generiert wird:
curl --libcurl code.c
https://www.westlotto.com/wlinfo/WL_Inf ... elplanTotoIm file "code.c" steht dann der entsprechende code, in diesem Fall:
Code:
CURLcode ret;
CURL *hnd;
hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_URL, "https://www.westlotto.com/wlinfo/WL_InfoService?gruppe=SpielplanToto");
curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/7.50.3");
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
ret = curl_easy_perform(hnd);
Die wichtige Option ist dabei der CURLOPT_USERAGENT ; ohne diese Zeile geht es nicht (also kommt die Reqest-denied Seite von oben als Ergebnis).
Will man das ganze noch in einem string speichern muss man noch einen callback einbauen:
Code:
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp) {
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}
CURLcode ret;
CURL *hnd;
std::string readBuffer;
hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_URL, "https://www.westlotto.com/wlinfo/WL_InfoService?gruppe=SpielplanToto");
curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/7.50.3");
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, &readBuffer);
ret = curl_easy_perform(hnd);
curl_easy_cleanup(hnd);
hnd = NULL;
std::cerr << readBuffer << std::endl;
Dann steht der Spielplan als xml im readBuffer string und kann an den xml-parser weitergereicht werden.
Mal schauen ob man so auch die Durchschnittsquoten von betexplorer abschnorcheln kann
