linux - 比较两个网站,看是不是 "equal?"

标签 linux apache webserver migration compare

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

最佳答案

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

w3m -dump http://google.com 2>/dev/null > /tmp/1.html
w3m -dump http://google.de 2>/dev/null > /tmp/2.html

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

wdiff -nis /tmp/1.html /tmp/2.html

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

wdiff -nis /tmp/1.html /tmp/2.html | colordiff

输出摘录:

Web Images Vidéos Maps [-Actualités-] Livres {+Traduction+} Gmail plus »
[-iGoogle |-]
Paramètres | Connexion

                           Google [hp1] [hp2]
                                  [hp3] [-Français-] {+Deutschland+}

           [                                                         ] Recherche
                                                                       avancéeOutils
                      [Recherche Google][J'ai de la chance]            linguistiques


/tmp/1.html: 43 words  39 90% common  3 6% deleted  1 2% changed
/tmp/2.html: 49 words  39 79% common  9 18% inserted  1 2% changed

(他居然把 google.com 变成了法语……好笑)

common % 值是两个文本的相似程度。此外,您可以轻松地按单词查看差异(而不是按行查看,这可能会很困惑)。

关于linux - 比较两个网站,看是不是 "equal?",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3286955/

相关文章:

php - Apache2返回php源码

apache - Hive日期功能实现星期几

PHP Mini 离线网络服务器?

java - 关于tomcat的负载能力(最好选择哪个版本?)

wolfram-mathematica - Mathematica 8.0 使用 HTTP POST 和 XML 与 Web 服务器 JSP 交互

linux - 关于Unix/Linux内核编程的问题

linux - 在 linux 上的 erlang shell 中配置键

python - 跟踪文本文件中读取的最后一行的最佳方法

c - 如何在 Linux 上将文件读入 C 程序?

apache - 如何从授权中排除某些IP