Comment detail

HTTPでGET その2 (Nested Flatten)

#3704 を元にしています。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <curlpp/cURLpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>
#include <string>

std::string content;

size_t writeMemoryCallback( char *ptr, size_t size, size_t nmemb  ){
   size_t realsize = size * nmemb;
   content.append(  static_cast<const char *>( ptr ), realsize );
   return realsize;
}

int main( int argc, char *argv[] ){

   try {
      cURLpp::Cleanup cleaner;
      cURLpp::Easy request;
      request.setOpt( new cURLpp::Options::Url( "http://ja.doukaku.org/feeds/comments/" ) );
      request.setOpt( new cURLpp::Options::WriteFunction(
                      cURLpp::Types::WriteFunctionFunctor( &writeMemoryCallback )));
      request.setOpt( new cURLpp::Options::Proxy( "example.com:80" ) );
      request.setOpt( new cURLpp::Options::Timeout( 1 ));
      request.perform();
   }
   catch ( cURLpp::LogicError & e ) {
      std::cerr << e.what() << std::endl;
      return 1;
   }
   catch ( cURLpp::RuntimeError & e ) {
      std::cerr << e.what() << std::endl;
      return 1;
   }
   std::cout << content << std::endl;
   return 0;
}

Index

Feed

Other

Link

Pathtraq

loading...