通过 wget 获取到内存&绕过磁盘写入
是否可以将网站内容(一组 HTML 页面)直接下载到内存而不写入磁盘?
我有一个机器集群,每台机器安装了 24G,但磁盘配额限制为几百 MB。我正在考虑将输出 wget 重定向到某种内存结构,而不将内容存储在磁盘上。另一个选择是创建我自己的 wget 版本,但可能有一种简单的方法可以使用管道来完成此操作
另外,并行运行此下载的最佳方法是什么(集群有 > >) 20 个节点)。在这种情况下无法使用文件系统。
Is it possible to download contents of a website—a set of HTML pages—straight to memory without writing out to disk?
I have a cluster of machines with 24G of installed each, but I’m limited by a disk quota to several hundreds MB. I was thinking of redirecting the output wget
to some kind of in-memory structure without storing the contents on a disk. The other option is to create my own version of wget
but may be there is a simple way to do it with pipes
Also what would be the best way to run this download in parallel (the cluster has >20 nodes). Can’t use the file system in this case.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
请参阅 wget 下载选项:
如果要将文件读入 Perl 程序,可以使用反引号调用
wget
。根据您真正需要做什么,您也许可以通过使用 LWP::Simple 的
get
。更新:我不知道您可以使用Fuse 和 Fuse.pm。另请参阅Fuse::InMemory。
See wget download options:
If you want to read the files into a Perl program, you can invoke
wget
using backticks.Depending on what you really need to do, you might be able to get by just using LWP::Simple's
get
.Update: I had no idea you could implement your own file system in Perl using Fuse and Fuse.pm. See also Fuse::InMemory.
如果您 a) 已经在使用 Perl,b) 想要下载 HTML,c) 解析它,我总是推荐 LWP 和 HTML::TreeBuilder。
If you a) are already using Perl, b) want to download HTML, and c) parse it, I always recommend LWP and HTML::TreeBuilder.
你是根吗?您可以只使用
tmpfs
。重新编辑:您不受 CPU 限制,不需要使用每台机器。您可以使用
xargs -n SOME_NUMBER
来拆分根网址列表(假设有多个)。但如果你热衷于共享内存,你可以设置一个集群memcache,并使用 memcachefs。
Are you root? You could just use a
tmpfs
.Re your edit: you're not CPU bound, you don't need to use every machine. You can use
xargs -n SOME_NUMBER
to split your list of root urls, assuming there are several.But if you are keen on sharing memory, you can set up a cluster memcache and mount it on every machine with memcachefs.
将 URL 的内容写入标准输出,然后可以在内存中捕获。
Will write the contents of a URL to standard output, which can then be captured in memory.