gpt4 book ai didi

linux - 如何修改下面的squid url_rewriting_program

转载 作者:太空宇宙 更新时间:2023-11-04 05:53:35 24 4
gpt4 key购买 nike

请修改上述程序,以便它用您选择的图片替换任何页面内的所有图像(例如 .jpg 或 .gif 图像)。当 HTML 网页包含图像时,浏览器将识别这些图像 URL,并发出每个图像的 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";
}
}

最佳答案

查看 if block 。它匹配 URL,然后执行操作。你只需要做类似的事情。

看看 perlrequick页面,快速概述正则表达式在 Perl 中的工作原理。

关于linux - 如何修改下面的squid url_rewriting_program,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23777005/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com