POCOã§ç°¡åWebã¢ã¯ã»ã¹
POCOã¨ããC++ç¨ã®ã©ã¤ãã©ãªï¼ã¨ã¦ãé¢ç½ãã§ãï¼
POCO C++ Libraries - Simplify C++ Development
ã¤ã³ã¹ãã¼ã«ãç°¡åã§ï¼makeä¸çºã§ãï¼ãã ï¼ç°¡åã¨ãããã¨ã¯ã«ã¹ã¿ãã¤ãºæ§ãä½ãï¼ä¾ãã°ç¾ç¶ã§ã¯icc(Intel C Compiler)ã§ä½ããã¨ãã§ãã¾ããï¼
ã§ãï¼æ§é ãç¾ããã¦åãããããï¼ç§ã«ã¯Rubyã®ä¾¿å©ãªæ·»ä»ã¯ã©ã¹ã©ã¤ãã©ãªã®ãããªå°è±¡ãåãã¾ããï¼Rubyã¯ãããã¯ã¼ã¯ããã°ã©ãã³ã°ãå¾æãªã®ã§ï¼ããã¶ãè²ã ãªã¢ããªãããããï¼ã¯ãã¼ã©ï¼ãä½ã£ã¦ã¿ã¾ãããï¼POCOã§ãåæ§ã«ç°¡åã«è²ã ãªãã¨ãã§ãããã§ãï¼
試ãã«ï¼Yahoo!ã®ããããã¼ã¸ãåã£ã¦ãã¦ï¼ãããã¨ããã£ã®HTMLãæ¨æºåºåã«è¡¨ç¤ºãããµã³ãã«ãæ¸ãã¦ã¿ã¾ããï¼
#include <iostream> #include <Poco/Net/HTTPClientSession.h> #include <Poco/Net/StreamSocket.h> #include <Poco/Net/SocketAddress.h> #include <Poco/Net/HTTPRequest.h> #include <Poco/Net/HTTPResponse.h> using namespace std; int main() { Poco::Net::HTTPClientSession client("www.yahoo.co.jp",80); // ã¢ã¯ã»ã¹å ã®è¨å® Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, "/"); // ã¢ã¯ã»ã¹æ¹æ³ã®è¨å® Poco::Net::HTTPResponse response; // çµæãåãåãç®±ã®æºå ostream &req = client.sendRequest(request); // ã¢ã¯ã»ã¹ãã istream &res = client.receiveResponse(response); // çµæãåå¾ãã int len = response.getContentLength(); // ãããã®Content-Lengthãåå¾ãã char *resbody = new char[len+1]; // ããã£ã®HTMLãå ¥ããé åã確ä¿ãã response.write(cout); // HTTPããããåºåãã res.read(resbody,len); // HTMLããã£ãåå¾ãã cout<<resbody<<endl; // HTMLããã£ãåºåãã return(0); }
20è¡ã¡ããã§æ¸ãã¾ããï¼
ã½ã±ããéä¿¡ã®ç¥èãå¿
è¦ããã¾ããï¼ãããè¯ãã®ãã£ã¦è©±ã¯ããã¾ããï¼ï¼ï¼ï¼ï¼
ãã¡ããï¼ããã®ã½ã±ããéä¿¡ã®ããã°ã©ã ãæ¸ãããã®ã¯ã©ã¹ãå
¥ã£ã¦ãã¾ãï¼