Search code examples
htmlrubystringnokogiri

How to compare two HTML page contents efficiently


I have two HTML pages, whose source code I want to compare. I have converted the page source to strings, and I need to know what will be the best way to compare both huge strings.

  • Shall I use normal compare methods e.g., page1.eql?(page2)?
  • Does str.eql?(str1) also compare symbols e.g., @?

I would really appreciate to know the best approach for comparison.


Solution

  • I'm not sure how detailed you want your comparison to be. If you want "diff-like" capabilities, you can check out a previous similar question asked: diff a ruby string or array