如何使用W3C的Checklink排除多个域

时间:2019-05-21 12:41:05

标签: regex w3c-validation

checklink命令支持--exclude参数,该参数接受正则表达式。示例:

checklink --exclude foo\.com/.* http://example.com

可惜,example.com链接到多个站点,其中许多站点都使用robots.txt阻止了检查链接,因此我在输出中得到了许多未经检查的链接消息。

如上所述,我已经排除了foo.com。如何排除多个域?如果我有多个--exclude参数,则仅纪念最后一个。

checklink --version给出“ W3C链接检查器版本4.81(c)1999-2011 W3C”; aptitude show w3c-linkchecker给出“版本4.81-9”;我在Debian Stable上。

1 个答案:

答案 0 :(得分:1)

Hooray用于调试橡皮鸭。

答案在正则表达式中。具体来说:

checklink --exclude "(foo|bar)\.com/.*" http://example.com

这不包括foo.com和bar.com上的所有页面。注意引号,括号和管道。

替代方案也可以嵌套:

checklink --exclude "(foo|b(ar|az))\.com/.*" http://example.com

这不包括foo.com,bar.com和baz.com上的所有页面。