C++ cURL 刷新页面

C++ cURL Refresh Page

我在 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: %s\n",
              curl_easy_strerror(res));

    /* always cleanup */ 
    curl_easy_cleanup(curl);
  }
    system("PAUSE");
    return EXIT_SUCCESS;
}

当我 运行 这个程序时,它会在控制台上显示 mypage.html 的源代码。接下来我更新了 mypage.html 的源代码并再次执行程序,但它再次在控制台上打印之前的源代码。问题在哪里?请帮助。

我认为您重写了页面的源代码,但请记住在网络服务器上更新页面或兑现页面

我最近遇到了同样的问题。但它适用于 WinINet,而不适用于 cURL。只是我将服务器上的 .html 文件更改为 .php 并且工作正常!实际上 .php 文件不会被浏览器缓存。所以试一试吧。