Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #55

Open
ghost opened this issue Apr 10, 2022 · 2 comments
Open

issue #55

ghost opened this issue Apr 10, 2022 · 2 comments

Comments

@ghost
Copy link

ghost commented Apr 10, 2022

how can i get web page body as string ?

@Altman-conquer
Copy link

Altman-conquer commented Aug 25, 2022

just like this
the result would be the page body
http::Request request{"http://test.com/test"};

@Eng-MohamedHussien
Copy link

Eng-MohamedHussien commented Nov 26, 2023

@venti-bit @Altman-conquer
General speaking body of a webpage always exists in the HTTP response body.
Check the following example:

#include <iostream>

#include "HTTPRequest.hpp"

int main()
{
    try
    {
        // you can pass http::InternetProtocol::V6 to Request to make an IPv6 request
        http::Request request{"http://info.cern.ch/hypertext/WWW/TheProject.html"};

        // send a get request
        const auto response = request.send("GET");
        std::cout << std::string{response.body.begin(), response.body.end()} << '\n'; // print the result
    }
    catch (const std::exception& e)
    {
        std::cerr << "Request failed, error: " << e.what() << '\n';
    }
    return 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants