[c ++]从网站文件中读取 [英] [c++] read from website file

查看:72
本文介绍了[c ++]从网站文件中读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Example :
<b>Read from website :</b> http://www.website.com/file.txt

This file will read each line individually.

and write. 

Example : line = 9 

int line = this file lines (9);

for (int i=0; i<=line;i++)
{
   cout << file[i] << "\n" << endl;
}

system("PAUSE");





我的尝试:



如何在网站上读取此文件?



What I have tried:

How do I read this file on the Web site?

推荐答案

您需要使用与服务器的套接字连接检索文件并使用HTTP GET命令请求它。您可以自己实现它,也可以使用提供必要功能的库(搜索C ++ HTTP客户端库)。



使用Windows查看 WinInet Basics [ ^ ]其中包含一个示例如何下载网页。



使用Linux查看通常包含类似示例的已使用库的文档。图书馆候选人是 libcurl - 多协议文件传输库 [ ^ ]和 cpp-netlib:C ++网络库 [ ^ ]。
You need to retrieve the file using a socket connection to the server and requesting it using the HTTP GET command. You can implement that yourself or use a library providing the necessary functions (search for "C++ HTTP client library").

With Windows see WinInet Basics[^] which contains an example on how to download a web page.

With Linux see the documentation of the used library which usually contains a similar example. Library candidates are libcurl - the multiprotocol file transfer library[^] and cpp-netlib: The C++ Network Library[^].


这篇关于[c ++]从网站文件中读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆