我在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的源代码并再次执行了该程序,但它再次在控制台上打印了以前的源代码。问题出在哪里?请帮助。
答案 0 :(得分:0)
我认为您重写了该页面的源代码,但请记住Web服务器或页面兑换的更新页面
答案 1 :(得分:0)
我最近遇到了同样的问题。但它与WinINet有关,而与cURL无关。我只是将我的.html文件更改为服务器上的.php,它工作正常!实际上.php文件没有被浏览器缓存。所以试一试。