Paozhu(炮竹🧨)是一个全面、快速的C++ web framework 开发框架,集成C++ ORM,开发速度跟脚本语言一样,日写1000行业务代码没有压力,框架集成了WebServer,自己原生解析HTTP/1、HTTP/2、JSON协议
Paozhu C++ Web Framework 1.4.6发布 新功能 添加 对httpclient 协程、异步、同步功能,可以应用于数据采集.
目前httpclient使用了线程池功能,配合协程可以做到几千并发采集。
具体演示例子已经添加到controller/src 目录。
//@urlpath(null,testcowaitclient2)
std::string testhttpclient_cowait_urls(std::shared_ptr peer)
{
httppeer &client = peer->getpeer();
client << "hello world!test testhttpclient_cowait_body";
http::client_context &client_context = get_client_context_obj();
//std::vector urls= {"https://gcc.gnu.org/gcc-12/changes.html", "https://www.php.net/docs.php", "https://gcc.gnu.org/gcc-13/changes.html"};
std::vector urls = {"https://www.php.net/docs.php"};
for (unsigned int i = 0; i < urls.size(); i++)
{
std::shared_ptr a = std::make_shared();
a->get(urls[i]);
if (a->host == "www.php.net")
{
a->addheader("Connection", "keep-alive");
}
a->onload = [](const std::string &respbody, std::shared_ptr a) -> void
{
if (a->host == "www.php.net" && a->path == "/docs.php")
{
a->get("https://www.php.net/manual/zh/copyright.php");
http::client_context &client_context_in = get_client_context_obj();
a->addheader("Connection", "Close");
client_context_in.add_http_task(a);
}
else if (a->host == "www.php.net" && a->path == "/manual/zh/copyright.php")
{
std::cout << respbody << std::endl;
}
};
client_context.add_http_task(a);
}
return "";
}
下一个小版本添加短信发送支持阿里云,腾讯云、网易云短信发布
https://github.com/hggq/paozhu