我们正在迁移网络服务器,如果能有一种自动化的方法来检查一些基本的站点结构,看看新服务器上呈现的页面是否与旧服务器上的页面相同,那就太好了。我只是想知道是否有人知道有什么可以协助完成这项任务?
最佳答案
获取两个站点的格式化输出(这里我们使用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/