通过将地址更改为 http 的脚本下载 ftp 链接
我用 tcl 编写了一个脚本,从一个巨大文档的下载部分获取链接,检查 http:// 和 ftp:// 作为下载链接。所有 ftp:// 链接都不需要密码/用户名,而不是在单独的情况下处理它们(将 ftp:// 传递给一种下载方法,将 http:// 传递给另一种下载方法),我只需将所有链接传递给一种方法是将 ftp:// 替换为 http://。
例如,如果我有 ftp://server.com/dir/big_file.zip 我会通过以及 http://server.com/dir/big_file.zip 并将其下载为那。
我用小样本进行测试时没有遇到任何问题(由于文件大小,测试需要很长时间),在我过夜运行下载所有内容之前,我想知道是否会出现任何可能的危险?我只需要下载,不需要上传,并且我确定所有 ftp 链接都没有用户/密码。
另外,我知道这可能是不好的做法,但是当没有用户名/密码时,使用 ftp:// 和 http:// 作为文件链接到底有什么区别?
I wrote a script in tcl to grab links out of the download portion of a huge document checking for http:// and ftp:// as links to download. All of the ftp:// links don't require password/username and instead of handling them in separate cases (passing ftp:// to one download method and http:// to another download method) I would just pass all links to one method and substitute ftp:// with http://.
e.g. if I have ftp://server.com/dir/big_file.zip I would pass that along as http://server.com/dir/big_file.zip and download it as that.
I haven't run into any problems testing this with a small sample (testing takes forever because of file sizes) and before I run this overnight to download everything I want to know if is there any possible dangers that will come up? I only need to download, don't need to upload and I'm sure all the ftp links don't have user/passwd.
Also, I know this is probably bad practice but what exactly is the difference between having ftp:// and http:// for a file link when there's no username/password?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果它们都来自同一服务器,则不会造成任何身份验证问题(如果它对某些服务器有效,那么它应该对所有服务器都有效)。 FTP 和 HTTP 在不同的端口上运行,因此使用其中之一会导致您通过不同的端口下载文件。有时 FTP 可能比 HTTP 更快(因为它用于文件传输),因此如果可以的话,最好使用 FTP。
If they are all from the same server, it wouldn't pose any authentication problems (if it worked for some, it should work for all of them). FTP and HTTP operate on different ports, so using one over the other would have you downloading the file over a different port. Sometimes FTP can be faster than HTTP (since it's meant for file transfer), so it might be better to use FTP if you can.
请记住,服务器完全可以通过 FTP 访问文件,而无需通过 HTTP 访问。我什至可以说这种情况相当普遍。话虽这么说,如果您访问的服务器确实以两种协议提供所有文件,那么您应该没问题。
如果某些文件可能无法通过 HTTP 获取,您可以尝试的一件事是在 HTTP 失败时使用原始 (FTP) url 作为后备。
Bear in mind that it's entirely possible for a server to make a file accessible via FTP without doing so for HTTP. I'd go so far as to say it's fairly common for that to be the case. That being said, if the server you're hitting does serve all files up in both protocols, then you should be fine.
In the case where some files may not be available via HTTP, one thing you might try is to have the original (FTP) url used as a fallback if the HTTP one fails.