All Projects → whoshuu → Cpr

whoshuu / Cpr

Licence: mit
C++ Requests: Curl for People, a spiritual port of Python Requests.

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to Cpr

curly.hpp
Simple cURL C++17 wrapper
Stars: ✭ 48 (-98.86%)
Mutual labels:  libcurl, requests
cpr
C++ Requests: Curl for People, a spiritual port of Python Requests.
Stars: ✭ 5,005 (+19.17%)
Mutual labels:  libcurl, requests
django-debug-toolbar-requests
A Django Debug Toolbar panel for most popular http library requests.
Stars: ✭ 16 (-99.62%)
Mutual labels:  requests
Begoneads
BeGoneAds is a script that puts some popular hosts file lists into the systems hosts file as a adblocker measure.
Stars: ✭ 314 (-92.52%)
Mutual labels:  requests
Requester
Powerful, modern HTTP/REST client built on top of the Requests library
Stars: ✭ 273 (-93.5%)
Mutual labels:  requests
shamrock
A Trefle API Library.
Stars: ✭ 25 (-99.4%)
Mutual labels:  requests
Sasila
一个灵活、友好的爬虫框架
Stars: ✭ 286 (-93.19%)
Mutual labels:  requests
request-extra
⚡️ Extremely stable HTTP request module built on top of libcurl with retries, timeouts and callback API
Stars: ✭ 14 (-99.67%)
Mutual labels:  libcurl
Webspider
在线地址: http://119.23.223.90:8000
Stars: ✭ 340 (-91.9%)
Mutual labels:  requests
Doh
stand-alone application for DoH (DNS-over-HTTPS) name resolves and lookups
Stars: ✭ 265 (-93.69%)
Mutual labels:  libcurl
Renrenbackup
A backup tool for renren.com
Stars: ✭ 309 (-92.64%)
Mutual labels:  requests
Php Curl Class
PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs
Stars: ✭ 2,903 (-30.88%)
Mutual labels:  requests
korbit-python
Korbit API wrapper for Python
Stars: ✭ 17 (-99.6%)
Mutual labels:  requests
Dianping textmining
大众点评评论文本挖掘,包括点评数据爬取、数据清洗入库、数据分析、评论情感分析等的完整挖掘项目
Stars: ✭ 289 (-93.12%)
Mutual labels:  requests
nap
Convenient way to request HTTP APIs
Stars: ✭ 42 (-99%)
Mutual labels:  requests
J.a.r.v.i.s
python powered Intelligent System
Stars: ✭ 325 (-92.26%)
Mutual labels:  requests
NetworkAgent
This package is meant to make http request of an easy way inspiren in the architecture of Moya package. This package is 100% free of dependencies and works with Combine api + Codable
Stars: ✭ 16 (-99.62%)
Mutual labels:  requests
stats
📊 Request statistics middleware that stores response times, status code counts, etc
Stars: ✭ 15 (-99.64%)
Mutual labels:  requests
Python3 Concurrency Pics 02
爬取 www.mzitu.com 全站图片,截至目前共5162个图集,16.5万多张美女图片,使用 asyncio 和 aiohttp 实现的异步版本只需要不到2小时就能爬取完成。按日期创建图集目录,保存更合理。控制台只显示下载的进度条,详细信息保存在日志文件中。支持异常处理,不会终止爬虫程序。失败的请求,下次再执行爬虫程序时会自动下载
Stars: ✭ 275 (-93.45%)
Mutual labels:  requests
Robotframework Requests
Robot Framework keyword library wrapper for requests
Stars: ✭ 345 (-91.79%)
Mutual labels:  requests

C++ Requests: Curl for People

Documentation CI Gitter

Announcements

TLDR

C++ Requests is a simple wrapper around libcurl inspired by the excellent Python Requests project.

Despite its name, libcurl's easy interface is anything but, and making mistakes misusing it is a common source of error and frustration. Using the more expressive language facilities of C++11, this library captures the essence of making network calls into a few concise idioms.

Here's a quick GET request:

#include <cpr/cpr.h>

int main(int argc, char** argv) {
    cpr::Response r = cpr::Get(cpr::Url{"https://api.github.com/repos/whoshuu/cpr/contributors"},
                      cpr::Authentication{"user", "pass"},
                      cpr::Parameters{{"anon", "true"}, {"key", "value"}});
    r.status_code;                  // 200
    r.header["content-type"];       // application/json; charset=utf-8
    r.text;                         // JSON text string
}

And here's less functional, more complicated code, without cpr.

Documentation

Documentation
You can find the latest documentation here. It's a work in progress, but it should give you a better idea of how to use the library than the tests currently do.

Features

C++ Requests currently supports:

  • Custom headers
  • Url encoded parameters
  • Url encoded POST values
  • Multipart form POST upload
  • File POST upload
  • Basic authentication
  • Bearer authentication
  • Digest authentication
  • NTLM authentication
  • Connection and request timeout specification
  • Timeout for low speed connection
  • Asynchronous requests
  • 🍪 support!
  • Proxy support
  • Callback interfaces
  • PUT methods
  • DELETE methods
  • HEAD methods
  • OPTIONS methods
  • PATCH methods
  • Thread Safe access to libCurl
  • OpenSSL and WinSSL support for HTTPS requests

Planned

For a quick overview about the planed features, have a look at the next Milestones.

Usage

CMake

If you already have a CMake project you need to integrate C++ Requests with, the primary way is to use fetch_content. Add the following to your CMakeLists.txt.

include(FetchContent)
FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/libcpr/cpr.git GIT_TAG 67e12da316754ff3c6c91b50aafb2658438f3c1e) # the commit hash for 1.7.0
FetchContent_MakeAvailable(cpr)

This will produce the target cpr::cpr which you can link against the typical way:

target_link_libraries(your_target_name PRIVATE cpr::cpr)

That should do it! There's no need to handle libcurl yourself. All dependencies are taken care of for you.

Packages for Linux Distributions

Alternatively, you may install a package specific to your Linux distribution. Since so few distributions currently have a package for cpr, most users will not be able to run your program with this approach.

Currently, we are aware of packages for the following distributions:

If there's no package for your distribution, try making one! If you do, and it is added to your distribution's repositories, please submit a pull request to add it to the list above. However, please only do this if you plan to actively maintain the package.

Requirements

The only explicit requirements are:

  • a C++11 compatible compiler such as Clang or GCC. The minimum required version of GCC is unknown, so if anyone has trouble building this library with a specific version of GCC, do let me know
  • If you would like to perform https requests OpenSSL and its development libraries are required.

Building cpr - Using vcpkg

You can download and install cpr using the vcpkg dependency manager:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install cpr

The cpr port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.

Building cpr - Using Conan

You can download and install cpr using the Conan package manager. Setup your CMakeLists.txt (see Conan documentation on how to use MSBuild, Meson and others) like this:

project(myproject CXX)

add_executable(${PROJECT_NAME} main.cpp)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) # Include Conan-generated file
conan_basic_setup(TARGETS) # Introduce Conan-generated targets

# depending on your conan and cmake configuration, you may need to set the used ABI:
# add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)  # uncomment/add this line if the build fails or you get a runtime error

target_link_libraries(${PROJECT_NAME} CONAN_PKG::cpr)

Create conanfile.txt in your source dir:

[requires]
cpr/1.6.2

[generators]
cmake

Install and run Conan, then build your project as always:

pip install conan
mkdir build
cd build
conan install ../ --build=missing
cmake ../
cmake --build .

The cpr package in Conan is kept up to date by Conan contributors. If the version is out of date, please create an issue or pull request on the conan-center-index repository.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].