在C ++中下载URL [英] Download a URL in C++

查看:192
本文介绍了在C ++中下载URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在C ++中下载网址。简单的例子:

I want to be able to download a URL in C++. Something as simple as:


std::string s;
s=download("http://www.example.com/myfile.html");

理想情况下,这将包括以下URL:

Ideally, this would include URLs like:

  • ftp://example.com/myfile.dat
  • file:///usr/home/myfile.dat
  • https://example.com/myfile.html

我在Boost中使用asio,但它似乎没有有用于处理协议如ftp和https的代码。现在我发现QT有更多我需要的( http://doc.trolltech.com/2.3/network .html )。

I was using asio in Boost, but it didn't really seem to have the code for handling protocols like ftp and https. Now I discovered QT has more what I need (http://doc.trolltech.com/2.3/network.html).

切换到Qt很有诱惑力,但它似乎有点重,并且与许多Boost功能相交。

It's tempting to make the switch to Qt, but it seems a bit heavy and intersects a lot of Boost functionality. Is it worth learning yet another API (Qt) or can Boost do more than I think?

推荐答案

不是一个直接的答案,但是,您可能想考虑 libCURL ,这几乎正是您的描述。

Not a direct answer, but you might like to consider libCURL, which is almost exactly what you describe.

有一些示例应用程序此处,特别是演示了如何简单的使用方式。

There are sample applications here, and in particular this demonstrates how simple usage can be.

这篇关于在C ++中下载URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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