C++ 如何通过http请求仅获取字符串名称

C++ 如何通过http请求仅获取字符串名称,c++,visual-c++,curl,httprequest,libcurl,C++,Visual C++,Curl,Httprequest,Libcurl,我正在为http请求编写代码以获取字符串消息。我不知怎么地成功了。下面是我通过curl请求http的代码 #include "stdafx.h" #include <stdio.h> #include "curl/curl.h" int main(void) { CURL *curl; CURLcode res; /* In windows, this will init the winsock stuff */ curl_global_init(CURL_GL

我正在为http请求编写代码以获取字符串消息。我不知怎么地成功了。下面是我通过curl请求http的代码

#include "stdafx.h"
#include <stdio.h>
#include "curl/curl.h"

int main(void)
{
  CURL *curl;
  CURLcode res;

  /* In windows, this will init the winsock stuff */ 
  curl_global_init(CURL_GLOBAL_ALL);

  /* get a curl handle */ 
  curl = curl_easy_init();
  if(curl) {
    /* First set the URL that is about to receive our POST. This URL can
       just as well be a https:// URL if that is what should receive the
       data. */ 
    curl_easy_setopt(curl, CURLOPT_URL, "http://192.168.1.7:8080/asigra_1/helloword.jsp");
    /* Now specify the POST data */ 
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "name=daniel&project=curl");

    /* 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);
  }
  curl_global_cleanup();
  system("pause");
  return 0;

}
我可以得到它的以下输出

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.or
g/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
hello word 

</body>
</html>Press any key to continue . . .

这是整个网页,我只需要在输出中输入hello world,而不是整个页面信息。我应该如何使用curl进行操作。

以下是一些资源,您可以从中选择,以根据需要编写代码:

演示如何将数据直接下载到自己的内存缓冲区中

演示如何在下载时执行另一个技巧并直接解析HTML。这个特定的例子使用LibTidy来完成这项工作,但是您当然可以选择使用其他东西,自己解析它


是一个C++实例,它使用LIXXML2解析下载的页面,这也是你所要的一个例子。