通过 wget 获取到内存&绕过磁盘写入

发布于 2024-08-17 07:58:15 字数 233 浏览 7 评论 0原文

是否可以将网站内容(一组 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

远昼 2024-08-24 07:58:15

请参阅 wget 下载选项

<块引用>

'-O 文件'

'--output-document=文件'

文档不会写入相应的文件,但所有文档都会连接在一起并写入文件。如果使用“-”作为文件,文档将打印到标准输出,禁用链接转换。 (使用“./-”打印到字面名称为“-”的文件。)

如果要将文件读入 Perl 程序,可以使用反引号调用 wget

根据您真正需要做什么,您也许可以通过使用 LWP::Simpleget

use LWP::Simple;
my $content = get("http://www.example.com/");
die "Couldn't get it!" unless defined $content;

更新:不知道您可以使用FuseFuse.pm。另请参阅Fuse::InMemory

See wget download options:

‘-O file’

‘--output-document=file’

The documents will not be written to the appropriate files, but all will be concatenated together and written to file. If ‘-’ is used as file, documents will be printed to standard output, disabling link conversion. (Use ‘./-’ to print to a file literally named ‘-’.)

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.

use LWP::Simple;
my $content = get("http://www.example.com/");
die "Couldn't get it!" unless defined $content;

Update: I had no idea you could implement your own file system in Perl using Fuse and Fuse.pm. See also Fuse::InMemory.

寻找一个思念的角度 2024-08-24 07:58:15

如果您 a) 已经在使用 Perl,b) 想要下载 HTML,c) 解析它,我总是推荐 LWPHTML::TreeBuilder

If you a) are already using Perl, b) want to download HTML, and c) parse it, I always recommend LWP and HTML::TreeBuilder.

万人眼中万个我 2024-08-24 07:58:15

你是根吗?您可以只使用 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.

-小熊_ 2024-08-24 07:58:15
wget <url> -O -

将 URL 的内容写入标准输出,然后可以在内存中捕获。

wget <url> -O -

Will write the contents of a URL to standard output, which can then be captured in memory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文