c++ - 使用 unix 下载 html 文件
问题描述
我想使用 c++ 下载一个 html 文件。我有一些适用于 Visual Studio 的代码,但我需要它在 unix 中运行并能够使用 gcc 进行编译。我发现很多与此类似的问题都有很好的答案,但在 unix 中没有任何效果。这是我在视觉工作室中完美运行的代码......
#include <urlmon.h>
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
char webAddress[256] = "https://www.ibm.com/us-en/?ar=1";
char szFileName[80] = "ibm.html";
HRESULT hr = URLDownloadToFile(NULL, webAddress, szFileName,0, NULL);
if (hr == S_OK)
{
ifstream fin(szFileName);
char szBuff[2048];
}
else
{
cout << "Operation failed with error code: " << hr << "\n";
}
return 0;
}
解决方案
推荐阅读
- javascript - 在 React TypeScript 中键入输入的 keyup
- wcf - 无法在 ASP.NET Core 5.0 下的 IIS 中托管 CoreWcf
- angular - 我想将日期转换为 dd-mm-yyyy
- python - 尝试从 gstreamer appsink 获取 numpy 图像导致缓冲区太小错误
- node.js - 是否有一种直接的方式来验证 Joi 中的多个条件
- python - SIFT 无法关联清晰相关的图像
- timer - 我想使用两个不同的时间通过单个 UART 发送和接收数据
- python - 如何使用 python 将特定的 xml 标签移动到新的 xml 文件?
- java - 使用 telnet 连接通过 java 代码向 Digi 发送 Ctrl+Break
- windows - 不能有一个零长度的 USB“串行”字符串描述符?