【发布时间】:2014-05-21 07:41:24
【问题描述】:
请修改上述程序,以便将任何页面内的所有图像(例如 .jpg 或 .gif 图像)替换为您选择的图片。当 HTML 网页包含图像时,浏览器将识别这些图像 URL,并为每个图像发送一个 URL 请求。您应该能够在您的 URL 重写程序中看到这些 URL。您只需要确定一个 URL 是否正在尝试获取特定类型的图像文件;如果是,您可以将 URL 替换为另一个(您的选择)。
use strict;
use warnings;
# Forces a flush after every write or print on the STDOUT
select STDOUT; $| = 1;
# Get the input line by line from the standard input.
# Each line contains an URL and some other information.
while (<>)
{
my @parts = split;
my $url = $parts[0];
# If you copy and paste this code from this PDF file,
# the ˜ (tilde) character may not be copied correctly.
# Remove it, and then type the character manually.
if ($url =˜ /www\.cis\.syr\.edu/) {
# URL Rewriting
print "http://www.yahoo.com\n";
}
else {
# No Rewriting.
print "\n";
}
}
【问题讨论】:
-
尝试编辑
/usr/local/squid/etc/squid.conf? -
这听起来像是家庭作业...