Click here to Skip to main content
15,896,444 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, guys,

I want to get content from a website, like:
https://example.com/data.txt

And let's say, data.txt has the following data:
data.txt
Hello, world!

And notice these lines from here:
oscfg.hpp
71] else if (cmd == "[login]") {
72] // Later...
73] } else {

Instead of that comment "Later...", I would like to insert code, which would cout out the contents of https://example.com/data.txt‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎

What I have tried:

‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎
Posted
Updated 22-Feb-22 5:40am
Comments
Richard MacCutchan 22-Feb-22 7:50am    
You first need to download the data into a local file. It is then a simple matter to read and display the contents.

Depends on what C++ framework you are using: if it's a .NET project, then there is the WebClient Class (System.Net) | Microsoft Docs[^] which includes the WebClient.DownloadFile Method (System.Net) | Microsoft Docs[^] which does it all for you in two lines of code.
 
Share this answer
 
Comments
Tyrunt.new("Rix") 22-Feb-22 6:46am    
I use Replit. So what is the correct software for that? ( Well I know that Replit's PC is Linux, because that's how bash works. )
Tyrunt.new("Rix") 22-Feb-22 6:50am    
( Also not download a page, but cout out the contents ( I mean, store the HTML into a variable, and then use cout << html to cout ou the variable, in which the HTML is stored. ) )
OriginalGriff 22-Feb-22 7:27am    
Did you look at the class methods available?
DownloadString for example? Or DownloadData?
:sigh:
Tyrunt.new("Rix") 22-Feb-22 8:55am    
I think you're telling me how to do that in C#, if so, this is C++
OriginalGriff 22-Feb-22 9:22am    
:sigh:
You do realize that C++ can use .NET as well? Just change the code sample language in the documentation ...
 
Share this answer
 
Comments
Tyrunt.new("Rix") 22-Feb-22 8:59am    
*Not Linux
You need to create a socket connection to the server, and use a GET request as described at HTTP Tutorial[^].
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900