如何以简洁的顺序排列 Perl :: Mechanize 的输出(使用变量或名称)
我运行linux opensuse 11.4。我尝试在 Linux 机器上运行这个小程序。
#!/usr/bin/perl
use WWW::Mechanize::Firefox;
my $mech = WWW::Mechanize::Firefox->new();
open(INPUT, "urls.txt") or die "Can't open file: $!";
while (<INPUT>) {
chomp;
$mech->get($_);
my $png = $mech->content_as_png();
}
close(INPUT);
exit;
我有一个 URL 列表 - 超过 1000 个 URL - 因此如果我以未排序的方式获得结果可能会出现问题。
我有一个包含 1000 个 URL 的列表,每行一个,保存在一个文件中。我希望上面的脚本打开文件,读取一行,然后检索网站! URL 的存储方式如下:
Filename: urls.txt
------------------
www.google.com
www.cnn.com
www.msnbc.com
news.bbc.co.uk
www.bing.com
www.yahoo.com
我如何编写脚本,以便缩略图像以特定名称存储 - 例如,以域名存储。否则结果就会一团糟。我需要根据 URL 识别缩略图。这可能吗?
I run linux opensuse 11.4. I try to run this little programme on a linux box.
#!/usr/bin/perl
use WWW::Mechanize::Firefox;
my $mech = WWW::Mechanize::Firefox->new();
open(INPUT, "urls.txt") or die "Can't open file: $!";
while (<INPUT>) {
chomp;
$mech->get($_);
my $png = $mech->content_as_png();
}
close(INPUT);
exit;
I have a list of URLS - more than 1000 URLS - so it might be a problem if I get the results in an unsorted way.
I have a list of 1000 URLs, one on each line, saved in a file. I want the script above to open the file, read a line, then retrieve the website! The URLS are stored something like this:
Filename: urls.txt
------------------
www.google.com
www.cnn.com
www.msnbc.com
news.bbc.co.uk
www.bing.com
www.yahoo.com
How can I write the script so that the thumbnail-images are stored with certain names - e.g., with the domain names. Otherwise the results would be a whole mess. I need to identify the thumbnails based on the URLS. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)