比较两个网站,看看它们是否“相等”?

Jos*_*eld 3 linux apache migration webserver compare

我们正在迁移 Web 服务器,如果有一种自动方法来检查一些基本站点结构,以查看新服务器上呈现的页面是否与旧服务器上的相同,那就太好了。我只是想知道是否有人知道有什么可以协助完成这项任务?

Web*_*ide 5

获取两个站点的格式化输出(这里我们使用w3m,但lynx也可以工作):

\n\n
w3m -dump http://google.com 2>/dev/null > /tmp/1.html\nw3m -dump http://google.de 2>/dev/null > /tmp/2.html\n
Run Code Online (Sandbox Code Playgroud)\n\n

然后使用wdiff,它可以为您提供两个文本相似程度的百分比。

\n\n
wdiff -nis /tmp/1.html /tmp/2.html\n
Run Code Online (Sandbox Code Playgroud)\n\n

使用colordiff也可以更容易地看到差异。

\n\n
wdiff -nis /tmp/1.html /tmp/2.html | colordiff\n
Run Code Online (Sandbox Code Playgroud)\n\n

输出摘录:

\n\n
Web Images Vid\xc3\xa9os Maps [-Actualit\xc3\xa9s-] Livres {+Traduction+} Gmail plus \xc2\xbb\n[-iGoogle |-]\nParam\xc3\xa8tres | Connexion\n\n                           Google [hp1] [hp2]\n                                  [hp3] [-Fran\xc3\xa7ais-] {+Deutschland+}\n\n           [                                                         ] Recherche\n                                                                       avanc\xc3\xa9eOutils\n                      [Recherche Google][J\'ai de la chance]            linguistiques\n\n\n/tmp/1.html: 43 words  39 90% common  3 6% deleted  1 2% changed\n/tmp/2.html: 49 words  39 79% common  9 18% inserted  1 2% changed\n
Run Code Online (Sandbox Code Playgroud)\n\n

(他实际上把 google.com 变成了法语......有趣)

\n\n

常见的%值是两个文本的相似程度。另外,您可以轻松地按单词查看差异(而不是按行查看,因为行可能会造成混乱)。

\n