Mam następujący kod w C ++
#include <cstdlib>
#include <iostream>
#include <curl/curl.h>
#include <string.h>
using namespace std;
int main(int argc, char *argv[])
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/mypage.html");
/* example.com is redirected, so we tell libcurl to follow redirection */
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %sn",
curl_easy_strerror(res));
/* always cleanup */
curl_easy_cleanup(curl);
}
system("PAUSE");
return EXIT_SUCCESS;
}
Kiedy uruchamiam ten program, pokazuje onkod źródłowy mypage.html na konsoli. Następnie zaktualizowałem kod źródłowy pliku mypage.html i ponownie wykonałem program, ale ponownie wydrukowałem poprzedni kod źródłowy na konsoli. Gdzie jest problem? Pomoc.
Odpowiedzi:
0 dla odpowiedzi № 1Ostatnio miałem ten sam problem. Ale to było z WinINet, a nie z cURL. Po prostu zmieniłem plik .html na .php na moim serwerze i wszystko działało dobrze! Właściwie pliki .php nie są buforowane przez przeglądarkę, więc spróbuj.
0 dla odpowiedzi nr 2
Myślę, że przepisujesz kod źródłowy strony, ale pamiętaj, że strona aktualizacji na serwerze lub stronie została spieniężona