如何在 Linux 中使用C++下载受密码保护的 URL
How to download a password protected URL using C++ in Linux?
首先,我不想入侵任何东西或任何人的电子邮件。
我是新的软件工程师,我需要登录公司维基页面并下载显示到文本文件或其他东西中的信息,这样我就可以搜索我正在寻找的数据,并根据我从维基页面学到的知识做出决定。我确实有维基页面的用户名和密码,不需要闯入。
问题是,我想不出一个好的方法。我正在使用C++操作系统是Linux。
这是我到目前为止所拥有的。这不会发出用户名和密码。有人可以告诉我如何发布用户名和密码吗?
string line; system("wget www.cooperateweb.com/wikipage/productpage/FWversions+date"); ifstream file ("index.html"); while (!file.eof()) { getline(file,line); cout<<line<<"n"; } file.close();
与任何URL相同。
scheme://username:password@host/path
来自全聚焦方式(TFM):
--user=user
--password=password
Specify the username user and password password for both FTP and HTTP
file retrieval. These parameters can be overridden using the --ftp-user
and --ftp-password options for FTP connections and the --http-user and
--http-password options for HTTP connections.
#define MAX_CMD_LENGTH 1000;
char cmdBuffer[MAX_CMD_LENGTH];
/* for sake of demonstration */
char *username = "foo";
char *password = "bar";
sprintf(cmdBuffer, "wget --user=%s --password=%s http://www.cooperateweb.com/wikipage/productpage/FWversions+date", username, password);
char *cmd = malloc(strlen(cmdBuffer) + 1);
strncpy(cmd, cmdBuffer, strlen(cmdBuffer) + 1);
system((const char *)cmd);
free(cmd);
恕我直言,最简单的方法是使用 curl。 Curl是一个比wget更复杂的Web客户端。
根据您的需求,最好的方法可能是基于 Boost 的 cpp-netlib。
相关文章:
- 有充分的理由在h文件中使用include保护而不是cpp文件吗
- 为什么在保护模式下继承升级不起作用
- 访问被拒绝后,c++中的故障保护代码
- C++:无法访问声明的受保护成员
- 为什么您需要C++头文件的包含保护
- lock_guard是否保护返回值
- 如何在GTK程序运行时禁用屏幕保护程序/电源管理/屏幕消隐
- 下载URL中的所有文件
- 如何使用 c++ 在 sqlite3 中打开受密码保护的数据库?
- 无法在 Cocos2dx 中使用受密码保护的 zip 文件
- 如何保护系统和数据库之间的密码
- 使用libcurl和C 将图片上传到密码保护的目录
- 如何使用MS CryptoAPI导出受密码保护的私钥
- 特征错误:请使用密码保护您的最小值
- 检测受密码保护的 MS Office 文件在 C/C++
- 如何在 Linux 中使用C++下载受密码保护的 URL
- QuaZip -密码保护的文件
- 密码保护嵌入式固件下载
- 我可以用密码保护应用程序吗
- 库解压缩密码保护的文件